Documentation ¶
Index ¶
- func GetLocalIP() (string, error)
- func GetRemoteIP() (string, error)
- type Sender
- func (s *Sender) HandleInterrupt()
- func (s *Sender) MainLoop()
- func (s *Sender) PrintTransferInfo(pauseDuration time.Duration)
- func (s *Sender) ReceivePackets()
- func (s *Sender) SendEncryptionKey() error
- func (s *Sender) SendOffer() error
- func (s *Sender) SendPiece() error
- func (s *Sender) Stop()
- func (s *Sender) StopListening()
- func (s *Sender) WaitForConnection()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLocalIP ¶
gets a local ip. Borrowed from StackOverflow, thank you, whoever I brought it from
func GetRemoteIP ¶
gets a remote ip. Borrowed from StackOverflow, thank you, whoever I brought it from
Types ¶
type Sender ¶
type Sender struct { Port int FileToTransfer *file Listener net.Listener Connection net.Conn IncomingPackets chan protocol.Packet EncryptionKey []byte TransferInfo *transferInfo TransferAllowed bool // the receiver had agreed to receive a file ReceiverIsReady bool // receiver is waiting for a new packet Stopped bool // controlls the mainloop }
The main sender struct
func (*Sender) HandleInterrupt ¶
func (s *Sender) HandleInterrupt()
When the interrupt signal is sent - exit cleanly
func (*Sender) MainLoop ¶
func (s *Sender) MainLoop()
The "head" of the sender. "Glues" all things together. Current structure allows the sender to receive any type of packet in any order and react correspondingly
func (*Sender) PrintTransferInfo ¶
Prints a brief information about the state of the transfer
func (*Sender) ReceivePackets ¶
func (s *Sender) ReceivePackets()
Listens in an endless loop; reads incoming packets, decrypts their BODY and puts into channel
func (*Sender) SendEncryptionKey ¶
Sends generated earlier eas encryption key to receiver
func (*Sender) SendOffer ¶
Sends multiple packets with all information about the file to receiver (filename, filesize, checksum)
func (*Sender) Stop ¶
func (s *Sender) Stop()
Closes the connection, warns about it the receiver and exits the mainloop
func (*Sender) StopListening ¶
func (s *Sender) StopListening()
Closes the listener. Used only when there is still no connection from `AcceptConnections`