minedive

package
v0.0.0-...-37d3c92 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Unlicense Imports: 22 Imported by: 0

README

minedive

Overview

godive is a rendez-vous server reference implementation for minedive.

minedive is a P2P privacy conscious distributed search engine embedden in a browser extension.

Installation

read the instruction in the root directory.

Documentation

More documentation about design and usage can be found in the Wiki

Documentation

Index

Constants

View Source
const (
	CircuitStateNewStr  = "new"
	CircuitStateKeysStr = "got all keys"
)
View Source
const (
	MinediveStateNewStr        = "new"
	MinediveStateConnectingStr = "connecting"
)
View Source
const (
	Unknown = 0
)

Variables

View Source
var (
	ErrUnknownType = errors.New("unknown")
)

Functions

func GetRandomName

func GetRandomName(id uint64, sseed string) string

func IncNonce

func IncNonce(a []byte, dyn int) error

func JSONSuccessExchange

func JSONSuccessExchange(cl *Client, in Cell, out *Cell)

func JSONSuccessSend

func JSONSuccessSend(cl *Client, in Cell)

func L1peerPing

func L1peerPing(cli *Client, p *L1Peer)

func UseNonce

func UseNonce(a []byte) (string, error)

Types

type Cell

type Cell struct {
	Type string `json:"type"`
	D0   string `json:"d0"`
	D1   string `json:"d1"`
	D2   string `json:"d2"`
	D3   string `json:"d3"`
}

func (*Cell) String

func (a *Cell) String() string

type Circuit

type Circuit struct {
	CircuitID string
	DC        *webrtc.DataChannel
	State     string
	Guard     Node
	Bridge    Node
	Exit      Node
	PubK      [32]byte
	PrivK     [32]byte

	Notification chan string
	CircuitEvent chan string
	// contains filtered or unexported fields
}

func (*Circuit) Send

func (c *Circuit) Send(msg string)

func (*Circuit) SetupCircuit

func (c *Circuit) SetupCircuit(guard string, bridge string, exit string)

func (*Circuit) StateOK

func (m *Circuit) StateOK() bool

type CircuitState

type CircuitState int
const (
	CircuitStateNew CircuitState = iota + 1
	CircuitStateKeys
)

func (CircuitState) String

func (t CircuitState) String() string

type Client

type Client struct {
	L1Peers   map[string]*L1Peer
	L2Peers   map[string]*L2Peer
	Searcher  func(*Client, string, string, string, string, string) //l2, q, lang, key, nonce
	Responder func(*Client, string)                                 //

	Verbose bool
	PrivK   [32]byte
	PK      [32]byte
	Browser bool

	Keys     map[string][32]byte
	Circuits []*Circuit
	Routes   map[string]*L1Peer

	Notification      chan string
	StateNotification chan MinediveState
	State             MinediveState
	// contains filtered or unexported fields
}

func DefaultDial

func DefaultDial(addr string) *Client

func Dial

func Dial(addr string) *Client

func DialMiddle

func DialMiddle(addr string) *Client

func DialOpts

func DialOpts(addr string, opts *DialOptions) *Client

func (*Client) AcceptAnswer

func (cli *Client) AcceptAnswer(target, sdp string)

func (*Client) AcceptOffer

func (cli *Client) AcceptOffer(target string, sdp string)

func (*Client) AddL2Peer

func (c *Client) AddL2Peer(l2 *L2Peer)

func (*Client) AddPeer

func (c *Client) AddPeer(p *L1Peer) bool

func (*Client) AskL2

func (c *Client) AskL2()

func (*Client) BuildCircuitZ

func (m *Client) BuildCircuitZ() (c *Circuit)

func (*Client) CreateOffer

func (cli *Client) CreateOffer(target string, alias string, exit bool)

func (*Client) DecL1Msg

func (cli *Client) DecL1Msg(p *L1Peer, msg webrtc.DataChannelMessage)

func (*Client) DecodeL2Msg

func (c *Client) DecodeL2Msg(l2 *L2Peer, emsg string) ([]byte, bool)

func (*Client) DeleteL2Peer

func (c *Client) DeleteL2Peer(name string)

func (*Client) DeletePeer

func (c *Client) DeletePeer(name string)

func (*Client) EncL1Msg

func (cli *Client) EncL1Msg(p *L1Peer, msg []byte)

func (*Client) GetL2Peer

func (c *Client) GetL2Peer(name string, gw *L1Peer, askKey bool) (*L2Peer, bool)

func (*Client) GetL2PeerIfExists

func (c *Client) GetL2PeerIfExists(name string) (*L2Peer, bool)

func (*Client) GetNL2Peers

func (c *Client) GetNL2Peers() int

func (*Client) GetNPeers

func (c *Client) GetNPeers() int

func (*Client) GetOtherPeers

func (c *Client) GetOtherPeers(name string) []string

func (*Client) GetPeer

func (c *Client) GetPeer(name string) (*L1Peer, bool)

func (*Client) GetPeerByAlias

func (c *Client) GetPeerByAlias(alias string) (*L1Peer, bool)

func (*Client) HandleL2Msg

func (c *Client) HandleL2Msg(gw *L1Peer, data []byte)

func (*Client) JCell

func (cli *Client) JCell(cell string)

func (*Client) KeepAlive

func (cli *Client) KeepAlive(interval time.Duration)

func (*Client) ListL1Peers

func (c *Client) ListL1Peers()

func (*Client) ListL2Peers

func (c *Client) ListL2Peers()

func (*Client) NewCircuit

func (m *Client) NewCircuit() (*Circuit, error)

func (*Client) NewL1Peer

func (cli *Client) NewL1Peer(name string, alias string, initiator bool, exit bool) (p *L1Peer)

func (*Client) PeerIsPresent

func (c *Client) PeerIsPresent(name string) bool

func (*Client) Redial

func (cli *Client) Redial() (err error)

func (*Client) RedialOpts

func (cli *Client) RedialOpts(add string, opts *DialOptions)

func (*Client) ReplyCircuit

func (m *Client) ReplyCircuit(msg string, eKey string, eNonce string)

needed: nonce, e.Key

func (*Client) SearchL2

func (c *Client) SearchL2(q string, lang string)

func (*Client) SendL2

func (c *Client) SendL2(l2 *L2Peer, b []byte) error

func (*Client) SingleCmd

func (cli *Client) SingleCmd(cmd string)

func (*Client) SinglePing

func (cli *Client) SinglePing()

func (*Client) WebSocketJSONDial

func (cli *Client) WebSocketJSONDial() (*websocket.Conn, error)

type ClientOptions

type ClientOptions struct {
	WSopts websocket.DialOptions
}

type DialOptions

type DialOptions struct {
	D0              string
	D1              string
	PublicKey       *[32]byte
	PrivateKey      *[32]byte
	ClientIsBrowser bool
}

type FwdMsg

type FwdMsg struct {
	From string `json:"from"`
	Type string `json:"type"`
	To   string `json:"to"`
	Msg  string `json:"msg"`
	Ori  string `json:"ori,omitempty"`
}

type L1Peer

type L1Peer struct {
	Name  string
	Alias string

	Exit bool
	K    [32]byte
	SDP  string
	// contains filtered or unexported fields
}

func (*L1Peer) Msg

func (p *L1Peer) Msg(msg string) error

type L2L1Msg

type L2L1Msg struct {
	From string   `json:"from"`
	Type string   `json:"type"`
	I    int      `json:"i"`
	L2   []string `json:"l2"`
}

type L2Msg

type L2Msg struct {
	Type  string   `json:"type"`
	Lang  string   `json:"l,omitempty"`
	Query string   `json:"q,omitempty"`
	Text  []string `json:"text,omitempty"`
}

type L2Peer

type L2Peer struct {
	Name       string
	GW         *L1Peer
	Inonce     [24]byte
	Ononce     [24]byte
	MsgIgnored int
	State      string
	K          [32]byte
	PK         [32]byte
}

type MinediveClient

type MinediveClient struct {
	ID         string
	Name       string
	TKID       string
	SecretKey  [32]byte //internally used???
	PublicKey  [32]byte //internally used???
	PubK       [32]byte
	Nonce      [24]byte
	RemoteAddr string
	Ws         *websocket.Conn
	Exit       bool
	Guard      bool
}

MinediveClient is the view the has of a connected client

func (*MinediveClient) GetAlias

func (gw *MinediveClient) GetAlias(username string) (string, error)

GetAlias return the name a peer is seen behind another peer

type MinediveServer

type MinediveServer struct {
	ServeMux http.ServeMux
	Dispatch func(*MinediveClient, Cell)
	// contains filtered or unexported fields
}

func (*MinediveServer) AddExit

func (s *MinediveServer) AddExit(cli *MinediveClient)

func (*MinediveServer) AddGuard

func (s *MinediveServer) AddGuard(cli *MinediveClient)

func (*MinediveServer) DecryptAlias

func (s *MinediveServer) DecryptAlias(alias string, gwName string) (string, error)

func (*MinediveServer) DelExit

func (s *MinediveServer) DelExit(cliName string)

func (*MinediveServer) DelGuard

func (s *MinediveServer) DelGuard(cliName string)

func (*MinediveServer) DeleteClientByName

func (s *MinediveServer) DeleteClientByName(name string) error

func (*MinediveServer) FwdToTarget

func (s *MinediveServer) FwdToTarget(m *Cell)

func (*MinediveServer) GetClientByName

func (s *MinediveServer) GetClientByName(name string) (*MinediveClient, error)

func (*MinediveServer) GetExit

func (s *MinediveServer) GetExit(avoid map[string]bool) (cli *MinediveClient, err error)

XXX recheck for skipped

func (*MinediveServer) GetExits

func (s *MinediveServer) GetExits() []string

func (*MinediveServer) GetGuard

func (s *MinediveServer) GetGuard(avoid map[string]bool) (cli *MinediveClient, err error)

func (*MinediveServer) GetGuards

func (s *MinediveServer) GetGuards() []string

func (*MinediveServer) GetOtherPeer

func (s *MinediveServer) GetOtherPeer(cli *MinediveClient) (*MinediveClient, error)

func (*MinediveServer) InitMinediveServer

func (s *MinediveServer) InitMinediveServer()

func (*MinediveServer) MinediveAccept

func (s *MinediveServer) MinediveAccept(w http.ResponseWriter, r *http.Request)

func (*MinediveServer) SendKey

func (s *MinediveServer) SendKey(c *MinediveClient, req *Cell)

func (*MinediveServer) SendPeer

func (s *MinediveServer) SendPeer(cli *MinediveClient)

type MinediveState

type MinediveState int
const (
	MinediveStateNew MinediveState = iota + 1
	MinediveStateConnecting
)

func (MinediveState) String

func (t MinediveState) String() string

type Node

type Node struct {
	ID    string
	OKey  [32]byte // own key
	TKey  [32]byte // temporary key
	LKey  [32]byte // long term key
	Nonce [24]byte
	State int
	Peer  *L1Peer
}

Directories

Path Synopsis
cmd
be

Jump to

Keyboard shortcuts

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