mutiiny

package module
v0.1.8-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

README

What am I?

Decentralised, encrpyted, and secure chat and multimedia protocol. Designed as a replacement for centralised, big-tech platforms. With mutiiny, anyone can setup their own server with minimal effort on nearly any hardware, and have control over their own hosted chat content. Unlike applications such as Discord, Mutiiny is simply a protocol. There is no central authority. This means that while server owners can mediate their own userbase, it is impossible to de-platform someone or to prevent them from using the protocol entirely.

What's to come?

  • Completed Mutiiny 1.0 Specification
  • Mutiiny Library Implementation
  • Basic Working Server

How does it work?

Being decentralised, anyone can set up a self-hosted Mutiiny server. Clients then exchange security details with the server and connect. Servers can be for a small group of users, or they can be used for large swaths of connections. Provided the hardware is up to the task, any configuration can be met.

❗The specification/implementation are both work in progress and in [VERY] early stages. Everything is subject for breaking changes without notice.

Documentation

Index

Constants

View Source
const (
	ADDR_INTERN string = "127.0.0.1"
	ADDR_ALL    string = "0.0.0.0"
	TCP_PORT    string = "14400"

	MAGIC_VAL string = "mutiiny"
	SEP_VAL   string = "*/MSEP/*"

	HEADER_SIZE uint8 = 8
	HEADER_PAD  uint8 = 2

	MESSAGE_DATA uint16 = 0
	CONNECT_DATA uint16 = 1
	QUIT_DATA    uint16 = 2
	ACCEPT_DATA  uint16 = 3
	DENY_DATA    uint16 = 4
	CLIENT_DATA  uint16 = 5

	ENCODE_TEXT string = "TEXT"
	ENCODE_PNG  string = "PNG"
	ENCODE_FILE string = "FILE"
)

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(key []byte, data []byte) []byte

func AESDeriveKey

func AESDeriveKey(pass []byte, salt []byte) []byte

func AESEncrypt

func AESEncrypt(key []byte, data []byte) []byte

func Deserialise

func Deserialise[T any](data []byte) *T

func GenerateProfile

func GenerateProfile(user, pass, path string) error

func GenerateValue32

func GenerateValue32() []byte

func RSABytesToPrivKey

func RSABytesToPrivKey(key []byte) (*rsa.PrivateKey, error)

func RSABytesToPubKey

func RSABytesToPubKey(key []byte) (*rsa.PublicKey, error)

func RSADecrypt

func RSADecrypt(priv *rsa.PrivateKey, data []byte) []byte

func RSAEncrypt

func RSAEncrypt(pub *rsa.PublicKey, data []byte) []byte

func RSAGenerateKeys

func RSAGenerateKeys() (*rsa.PrivateKey, *rsa.PublicKey)

func RSAPrivKeyToBytes

func RSAPrivKeyToBytes(key *rsa.PrivateKey) []byte

func RSAPubKeyToBytes

func RSAPubKeyToBytes(key *rsa.PublicKey) []byte

func RSASign

func RSASign(priv *rsa.PrivateKey, data []byte) []byte

func RSAVerify

func RSAVerify(pub *rsa.PublicKey, data []byte, sig []byte) bool

func RemoveEndpoint

func RemoveEndpoint(list *[]*Endpoint, index int)

func RemoveServerEndpoint

func RemoveServerEndpoint(list *[]*ServerEndpoint, index int)

func SHA256Hash

func SHA256Hash(data []byte) []byte

func Serialise

func Serialise[T any](t *T) []byte

Types

type AcceptData

type AcceptData struct {
	Name       string
	PublicKey  *rsa.PublicKey
	Signature  []byte
	SessionKey []byte
	Config     *ServerConfig
}

func NewAcceptData

func NewAcceptData(auth *Authenticator, config *ServerConfig, sk []byte) *AcceptData

type Authenticator

type Authenticator struct {
	Name       string
	PublicKey  *rsa.PublicKey
	PrivateKey *rsa.PrivateKey
}

func LoadProfile

func LoadProfile(user, pass, path string) (*Authenticator, error)

type Callbacks

type Callbacks struct {
	OnRecieve func(*Transmission, *ServerEndpoint)
	OnAccept  func(*ServerEndpoint)
	OnRemove  func(*ServerEndpoint)
}

type Client

type Client struct {
	Callbacks *Callbacks
	Servers   []*ServerEndpoint
	Alive     bool
	*Authenticator
}

func NewClient

func NewClient(callback *Callbacks, user, pass, path string) (*Client, error)

func (*Client) Connect

func (c *Client) Connect(address string) error

func (*Client) WaitForQuit

func (c *Client) WaitForQuit()

type ClientListData

type ClientListData struct {
	Names []string
}

func NewClientListData

func NewClientListData(clients []*Endpoint) *ClientListData

func (*ClientListData) Print

func (cl *ClientListData) Print()

type ConnectData

type ConnectData struct {
	Name      string
	PublicKey *rsa.PublicKey
	Signature []byte
}

func NewConnectData

func NewConnectData(auth *Authenticator) *ConnectData

type Endpoint

type Endpoint struct {
	Name       string
	SessionKey []byte
	PublicKey  *rsa.PublicKey
	Conn       net.Conn
	Ready      bool
}

func GetEndpointFromConn

func GetEndpointFromConn(list *[]*Endpoint, conn net.Conn) (int, *Endpoint)

func (*Endpoint) Print

func (e *Endpoint) Print()

func (*Endpoint) Recieve

func (e *Endpoint) Recieve() (*Transmission, error)

func (*Endpoint) Transmit

func (e *Endpoint) Transmit(tm *Transmission) error

type MessageData

type MessageData struct {
	Sender   string
	Channel  string
	Encoding string
	Data     []byte
}

func NewTextMessage

func NewTextMessage(sender, channel, text string) *MessageData

func (*MessageData) Print

func (m *MessageData) Print()

type Server

type Server struct {
	Listener net.Listener
	Clients  []*Endpoint
	Alive    bool
	*Authenticator
	*ServerConfig
}

func NewServer

func NewServer(user, pass, path, address string, config *ServerConfig) (*Server, error)

func (*Server) Broadcast

func (s *Server) Broadcast(tm *Transmission)

func (*Server) Process

func (s *Server) Process()

type ServerConfig

type ServerConfig struct {
	Channels []string
}

type ServerEndpoint

type ServerEndpoint struct {
	*Endpoint
	*ServerConfig
}

func GetServerEndpointFromConn

func GetServerEndpointFromConn(list *[]*ServerEndpoint, conn net.Conn) (int, *ServerEndpoint)

type Transmission

type Transmission struct {
	Size uint32
	Type uint16
	Data []byte
}

func NewTransmission

func NewTransmission[T any](dataType uint16, data *T) *Transmission

func (*Transmission) Decrypt

func (tm *Transmission) Decrypt(key []byte) *Transmission

func (*Transmission) Encrypt

func (tm *Transmission) Encrypt(key []byte) *Transmission

func (*Transmission) Print

func (tm *Transmission) Print()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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