client

package
v0.0.0-...-465a192 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MsTimeStamp

func MsTimeStamp(t time.Time) int64

MsTimeStamp converts time.Time into int64

func MsTimeStampNow

func MsTimeStampNow() int64

MsTimeStampNow returns the current timestamp, in milliseconds.

Types

type ClientState

type ClientState struct {
	DCNet *dcnet.DCNetEntity

	DataForDCNet               chan []byte //Data to the relay : VPN / SOCKS should put data there !
	NextDataForDCNet           *[]byte     //if not nil, send this before polling DataForDCNet
	DataFromDCNet              chan []byte //Data from the relay : VPN / SOCKS should read data from there !
	DataOutputEnabled          bool        //if FALSE, nothing will be written to DataFromDCNet
	HashFromPreviousMessage    [32]byte
	MyLastRound                int32
	LastMessage                []byte
	B_echo_last                byte
	DisruptionWrongBitPosition int

	EphemeralPublicKey kyber.Point
	ID                 int
	LatencyTest        *prifilog.LatencyTests
	MySlot             int
	Name               string

	PayloadSize int

	PublicKey kyber.Point

	TrusteePublicKey          []kyber.Point
	UseSocksProxy             bool
	UseUDP                    bool
	MessageHistory            kyber.XOF
	StartStopReceiveBroadcast chan bool

	DisruptionProtectionEnabled   bool
	LastWantToSend                time.Time
	EquivocationProtectionEnabled bool
	EphemeralPublicKeys           []kyber.Point
	// TEST DISRUPTION
	ForceDisruptionSinceRound3 bool
	AllreadyDisrupted          bool

	//concurrent stuff
	RoundNo           int32
	BufferedRoundData map[int32]net.REL_CLI_DOWNSTREAM_DATA
	// contains filtered or unexported fields
}

ClientState contains the mutable state of the client.

type PCAPReplayer

type PCAPReplayer struct {
	Enabled    bool
	PCAPFolder string
	PCAPFile   string
	Packets    []utils.Packet
	// contains filtered or unexported fields
}

PCAPReplayer handles the data needed to replay some .pcap file

type PriFiLibClientInstance

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

PriFiLibInstance contains the mutable state of a PriFi entity.

func NewClient

func NewClient(doLatencyTest bool, dataOutputEnabled bool, dataForDCNet chan []byte, dataFromDCNet chan []byte, doReplayPcap bool, pcapFolder string, msgSender *net.MessageSenderWrapper) *PriFiLibClientInstance

NewClient creates a new PriFi client entity state.

func (*PriFiLibClientInstance) ProcessDownStreamData

func (p *PriFiLibClientInstance) ProcessDownStreamData(msg net.REL_CLI_DOWNSTREAM_DATA) error

ProcessDownStreamData handles the downstream data. After determining if the data is for us, we test if it's a latency-test message, test if the resync flag is on (which triggers a re-setup). When this function ends, it calls SendUpstreamData() which continues the communication loop.

func (*PriFiLibClientInstance) ReceivedMessage

func (p *PriFiLibClientInstance) ReceivedMessage(msg interface{}) error

ReceivedMessage must be called when a PriFi host receives a message. It takes care to call the correct message handler function.

func (*PriFiLibClientInstance) Received_ALL_ALL_PARAMETERS

func (p *PriFiLibClientInstance) Received_ALL_ALL_PARAMETERS(msg net.ALL_ALL_PARAMETERS) error

Received_ALL_CLI_PARAMETERS handles ALL_CLI_PARAMETERS messages. It uses the message's parameters to initialize the client.

func (*PriFiLibClientInstance) Received_ALL_ALL_SHUTDOWN

func (p *PriFiLibClientInstance) Received_ALL_ALL_SHUTDOWN(msg net.ALL_ALL_SHUTDOWN) error

Received_ALL_CLI_SHUTDOWN handles ALL_CLI_SHUTDOWN messages. When we receive this message, we should clean up resources.

func (*PriFiLibClientInstance) Received_REL_ALL_DISRUPTION_REVEAL

func (p *PriFiLibClientInstance) Received_REL_ALL_DISRUPTION_REVEAL(msg net.REL_ALL_DISRUPTION_REVEAL) error

* Received_REL_ALL_DISRUPTION_REVEAL handles REL_ALL_DISRUPTION_REVEAL messages. * The method calls a function from the DCNet to regenerate the bits from roundID in position BitPos * The result is sent to the relay.

func (*PriFiLibClientInstance) Received_REL_ALL_REVEAL_SHARED_SECRETS

func (p *PriFiLibClientInstance) Received_REL_ALL_REVEAL_SHARED_SECRETS(msg net.REL_ALL_REVEAL_SHARED_SECRETS) error

* Received_REL_ALL_REVEAL_SHARED_SECRETS handles REL_ALL_REVEAL_SHARED_SECRETS messages. * The method gets the shared secret and sends it to the relay.

func (*PriFiLibClientInstance) Received_REL_CLI_DOWNSTREAM_DATA

func (p *PriFiLibClientInstance) Received_REL_CLI_DOWNSTREAM_DATA(msg net.REL_CLI_DOWNSTREAM_DATA) error

Received_REL_CLI_DOWNSTREAM_DATA handles REL_CLI_DOWNSTREAM_DATA messages which are part of PriFi's main loop. This is what happens in one round, for this client. We receive some downstream data. It should be encrypted, and we should test if this data is for us or not; if so, push it into the SOCKS/VPN chanel. For now, we do nothing with the downstream data. Once we received some data from the relay, we need to reply with a DC-net cell (that will get combined with other client's cell to produce some plaintext). If we're lucky (if this is our slot), we are allowed to embed some message (which will be the output produced by the relay). Either we send something from the SOCKS/VPN data, or if we're running latency tests, we send a "ping" message to compute the latency. If we have nothing to say, we send 0's.

func (*PriFiLibClientInstance) Received_REL_CLI_TELL_EPH_PKS_AND_TRUSTEES_SIG

func (p *PriFiLibClientInstance) Received_REL_CLI_TELL_EPH_PKS_AND_TRUSTEES_SIG(msg net.REL_CLI_TELL_EPH_PKS_AND_TRUSTEES_SIG) error

Received_REL_CLI_TELL_EPH_PKS_AND_TRUSTEES_SIG handles REL_CLI_TELL_EPH_PKS_AND_TRUSTEES_SIG messages. These are sent after the Shuffle protocol has been done by the Trustees and the Relay. The relay is sending us the result, so we should check that the protocol went well : 1) each trustee announced must have signed the shuffle 2) we need to locate which is our slot When this is done, we are ready to communicate ! As the client should send the first data, we do so; to keep this function simple, the first data is blank (the message has no content / this is a wasted message). The actual embedding of data happens only in the "round function", that is Received_REL_CLI_DOWNSTREAM_DATA().

func (*PriFiLibClientInstance) Received_REL_CLI_TELL_TRUSTEES_PK

func (p *PriFiLibClientInstance) Received_REL_CLI_TELL_TRUSTEES_PK(trusteesPks []kyber.Point) error

Received_REL_CLI_TELL_TRUSTEES_PK handles REL_CLI_TELL_TRUSTEES_PK messages. These are sent when we connect. The relay sends us a pack of public key which correspond to the set of pre-agreed trustees. Of course, there should be check on those public keys (each client need to trust one), but for now we assume those public keys belong indeed to the trustees, and that clients have agreed on the set of trustees. Once we receive this message, we need to reply with our Public Key (Used to derive DC-net secrets), and our Ephemeral Public Key (used for the Shuffle protocol)

func (*PriFiLibClientInstance) Received_REL_CLI_UDP_DOWNSTREAM_DATA

func (p *PriFiLibClientInstance) Received_REL_CLI_UDP_DOWNSTREAM_DATA(msg net.REL_CLI_DOWNSTREAM_DATA_UDP) error

Received_REL_CLI_UDP_DOWNSTREAM_DATA handles REL_CLI_UDP_DOWNSTREAM_DATA messages which are part of PriFi's main loop. This is what happens in one round, for this client. We receive some downstream data. It should be encrypted, and we should test if this data is for us or not; is so, push it into the SOCKS/VPN chanel. For now, we do nothing with the downstream data. Once we received some data from the relay, we need to reply with a DC-net cell (that will get combined with other client's cell to produce some plaintext). If we're lucky (if this is our slot), we are allowed to embed some message (which will be the output produced by the relay). Either we send something from the SOCKS/VPN data, or if we're running latency tests, we send a "ping" message to compute the latency. If we have nothing to say, we send 0's.

func (*PriFiLibClientInstance) SendUpstreamData

func (p *PriFiLibClientInstance) SendUpstreamData(ownerSlotID int) error

SendUpstreamData determines if it's our round, embeds data (maybe latency-test message) in the payload if we can, creates the DC-net cipher and sends it to the relay.

func (*PriFiLibClientInstance) WantsToTransmit

func (p *PriFiLibClientInstance) WantsToTransmit() bool

WantsToTransmit returns true if [we have a latency message to send] OR [we have data to send]

Jump to

Keyboard shortcuts

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