network

package
v0.0.0-...-7ce9f83 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// PingMsg - message received from the clients.
	PingMsg = "ping"
	// PongMsg - message sent back to the clients.
	PongMsg = "pong"
)

Variables

This section is empty.

Functions

func RetryingDialer

func RetryingDialer(sleep, timeout time.Duration, sideEffect func()) func(addr, port string) (conn net.Conn, err error)

RetryingDialer tries to establish a TCP connection to a socket until the timeout is reached.

func RetryingDialerWithContext

func RetryingDialerWithContext(sleep time.Duration, timeout time.Duration, l *zap.SugaredLogger) func(ctx context.Context, addr, port string) (conn net.Conn, err error)

RetryingDialerWithContext tries to establish a TCP connection to a socket until the timeout is reached or the context is cancelled.

func RetryingDialerWithContextAndLogTimeout

func RetryingDialerWithContextAndLogTimeout(sleep time.Duration, timeout time.Duration, l *zap.SugaredLogger, logPeriod time.Duration) func(ctx context.Context, addr, port string) (conn net.Conn, err error)

RetryingDialerWithContextAndLogTimeout uses an individual log message timer.

Used for testing

Types

type AbstractProxy

type AbstractProxy interface {
	Run(*CtxConfig, chan error) error
	Stop()
}

AbstractProxy is an interface for proxy.

type NetworkChecker

type NetworkChecker interface {
	Verify(string, string) error
}

NetworkChecker verifies the network connectivity between the players before starting the computation.

type NoopChecker

type NoopChecker struct {
}

NoopChecker verifies the network for all MPC players is in place.

func (*NoopChecker) Verify

func (t *NoopChecker) Verify(host, port string) error

Verify checks network connectivity between the players and communicates its results to discovery and players FSM.

type PingAwareTarget

type PingAwareTarget struct {
	Next   tcpproxy.Target
	Logger *zap.SugaredLogger
}

PingAwareTarget is a target that notifies about the start of the listener by means of the ping message.

func (*PingAwareTarget) HandleConn

func (n *PingAwareTarget) HandleConn(conn net.Conn)

HandleConn checks whether the byte stream contains ping. If it is a ping, we respond back with pong indicating the listener has started. The sender of the ping is responsible for closing the connection. In case of no ping, the data is forwarded to the Next Target.

func (*PingAwareTarget) WaitUntilStarted

func (n *PingAwareTarget) WaitUntilStarted(address, port string, timeout time.Duration, dial func(string, string) (net.Conn, error)) (bool, error)

WaitUntilStarted pings a proxy, waits for the pong and closes the connection.

type Proxy

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

Proxy is a wrapper around the tcpproxy and ping aware proxy. It establishes the connection between MPC master and slave.

func NewProxy

func NewProxy(lg *zap.SugaredLogger, conf *SPDZEngineTypedConfig, checker NetworkChecker) *Proxy

NewProxy returns a new instance of ephemeral proxy.

func (*Proxy) Run

func (p *Proxy) Run(ctx *CtxConfig, errCh chan error) error

Run start the tcpproxy, makes sure it has started by means of a ping.

func (*Proxy) Stop

func (p *Proxy) Stop()

Stop closes the underlying tcpproxy and waits for it to finish.

type TCPChecker

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

TCPChecker verifies the network for all MPC players is in place.

func NewTCPChecker

func NewTCPChecker(conf *TCPCheckerConf) *TCPChecker

NewTCPChecker returns an instance of TCPChecker

func (*TCPChecker) Verify

func (t *TCPChecker) Verify(host, port string) error

Verify checks network connectivity between the players and communicates its results to discovery and players FSM.

type TCPCheckerConf

type TCPCheckerConf struct {
	DialTimeout  time.Duration
	RetryTimeout time.Duration
	Logger       *zap.SugaredLogger
}

TCPCheckerConf is the configuration of TCPChecker

Jump to

Keyboard shortcuts

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