services

package
v0.0.0-...-723dd0c Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommunicationChannelTCPConfirm chan ConfirmMessageChannel
View Source
var CommunicationChannelTCPMessages chan TCPMessageChannel
View Source
var CommunicationChannelUDPMessages chan []byte

GLobal channel for messages from TCP

View Source
var CummunicationChannelError chan ChannelError

GLobal channel for communication errors and messages from TCP and special confirm messages for the peerController

Functions

func ComputeEphemeralKey

func ComputeEphemeralKey(g *dhkx.DHGroup, receivedPublicKey []byte, priv *dhkx.DHKey) []byte

Compute an ephemeral key using DH algorithm

func CreateConfirmTunnelCronstructionMessage

func CreateConfirmTunnelCronstructionMessage(confirmTunnelConstruction models.ConfirmTunnelConstruction) []byte

func CreateConfirmTunnelInstruction

func CreateConfirmTunnelInstruction(confirmTunnelInstruction models.ConfirmTunnelInstruction) []byte

func CreateConstructTunnelMessage

func CreateConstructTunnelMessage(constructTunnel models.ConstructTunnel) []byte

Function to create Construct Tunnel Messages. Type: 567.

func CreateDataConfirmTunnelConstruction

func CreateDataConfirmTunnelConstruction(dataConfirmTunnelConstruction models.DataConfirmTunnelConstruction) []byte

func CreateDataConstructTunnel

func CreateDataConstructTunnel(dataConstructTunnel models.DataConstructTunnel) []byte

func CreateDataExchangeKey

func CreateDataExchangeKey(exchangeKey models.ExchangeKey) []byte

func CreateExchangeKey

func CreateExchangeKey(exchangeKey models.ExchangeKey) []byte

func CreateInitialUDPConnectionLeft

func CreateInitialUDPConnectionLeft(leftHost string, leftPort int, tunndelId uint32) (*models.UDPConnection, error)

When Creating Initial (despite first element in tunnel), always set writer for left side >> Write back to origin

func CreateInitialUDPConnectionRight

func CreateInitialUDPConnectionRight(rightHost string, rightPort int, tunndelId uint32) (*models.UDPConnection, error)

func CreateOnionTunnelBuild

func CreateOnionTunnelBuild(onionTunnelBuild models.OnionTunnelBuild) []byte

func CreateOnionTunnelData

func CreateOnionTunnelData(onionTunnelData models.OnionTunnelData) []byte

func CreateOnionTunnelDestroy

func CreateOnionTunnelDestroy(onionTunnelDestroy models.OnionTunnelDestroy) []byte

func CreateOnionTunnelError

func CreateOnionTunnelError(onionError models.OnionError) []byte

func CreateOnionTunnelIncoming

func CreateOnionTunnelIncoming(onionTunnelIncoming models.OnionTunnelIncoming) []byte

func CreateOnionTunnelReady

func CreateOnionTunnelReady(onionTunnelReady models.OnionTunnelReady) []byte

func CreateOnionTunnelTrafficJamTCP

func CreateOnionTunnelTrafficJamTCP(tunnelTrafficJam models.OnionTunnelTrafficJam) []byte

func CreateRPSQuery

func CreateRPSQuery() []byte

func CreateTunnelID

func CreateTunnelID() uint32

TunnelID: 32 bits.

func CreateTunnelInstruction

func CreateTunnelInstruction(tunnelInstruction models.TunnelInstruction) []byte

func CreateUDPWriter

func CreateUDPWriter(destinationAddress string, destinationPort int) (net.Conn, error)

Creates a new writer for a given ip and port

func DecryptData

func DecryptData(key []byte, data []byte) ([]byte, error)

Decrypt Data with DH key.

func DecryptKeyExchange

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

Decrypt DH key for key exchange

func EncryptData

func EncryptData(key []byte, data []byte) ([]byte, error)

Encrypt Data with DH key.

func EncryptKeyExchange

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

Encrypt DH key for key exchange

func GenRandomData

func GenRandomData() []byte

used to generate random data

func GenerateIdentityOfKey

func GenerateIdentityOfKey(pubKey *rsa.PublicKey) []byte

Generates an identity byte array based on SHA256 Hash

func GeneratePreMasterKey

func GeneratePreMasterKey() (*dhkx.DHKey, []byte, *dhkx.DHGroup)

Generate a pre-master key for DH algorithm

func GetFreePort

func GetFreePort() (int, error)

getFreePort returns a new free port

func GetIPOutOfAddr

func GetIPOutOfAddr(addr string) string

func NewConfigObject

func NewConfigObject() (*models.Config, error)

NewConfigObject creates a new config struct based on an config.ini file, passed as parameter

func ParseKeys

func ParseKeys(path string) (*rsa.PrivateKey, *rsa.PublicKey, error)

Parse RSA keys (used for DH key exchange) from given path

func ScanCRLF

func ScanCRLF(data []byte, atEOF bool) (advance int, token []byte, err error)

Types

type ChannelError

type ChannelError struct {
	TunnelId uint32
	Error    error
}

ChannelError contains error and the tunnel id

type ConfirmMessageChannel

type ConfirmMessageChannel struct {
	TunnelId uint32
}

type Peer

type Peer struct {
	PeerObject *models.Peer
}

Just used to wrap the actual Peer from models.Peer here to use it as caller

func CreateNewPeer

func CreateNewPeer(config *models.Config) (*Peer, error)

CreatePeer crates a new Peer object that is just listening, now writing necessary at the moment

func (*Peer) AppendNewUDPConnection

func (peer *Peer) AppendNewUDPConnection(myUDPConnectio *models.UDPConnection)

func (*Peer) CreateInitialTCPConnection

func (peer *Peer) CreateInitialTCPConnection(tunnelId uint32, finalDestinationHostkey []byte, leftWriter *models.TCPWriter, originHostkey []byte)

Creates a new TCPConnection for the peer with the left writer already set

func (*Peer) CreateTCPWriter

func (peer *Peer) CreateTCPWriter(destinationIP string, tcpPort int) (*models.TCPWriter, error)

func (*Peer) StartTCPListening

func (peer *Peer) StartTCPListening()

StartTCPListening lets the peer listen for new TCP-messages on its P2P_Port

func (*Peer) StartUDPListening

func (peer *Peer) StartUDPListening()

StartUDPListening lets the peer listen for new UDP-messages

type TCPMessageChannel

type TCPMessageChannel struct {
	Message []byte
	Host    string // Attention, hast port
}

Used to transmit the message and the ip in the CommunicationChannelTCPMessages

type UDPConnection

type UDPConnection struct {
	UCPConnObject *models.UDPConnection
}

Just used to wrap the actual Peer from models.Peer here to use it as caller

Jump to

Keyboard shortcuts

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