Module: Lanet

Defined in:
lib/lanet.rb,
lib/lanet/cli.rb,
lib/lanet/mesh.rb,
lib/lanet/ping.rb,
lib/lanet/sender.rb,
lib/lanet/signer.rb,
lib/lanet/scanner.rb,
lib/lanet/version.rb,
lib/lanet/receiver.rb,
lib/lanet/encryptor.rb,
lib/lanet/traceroute.rb,
lib/lanet/file_transfer.rb

Defined Under Namespace

Classes: CLI, Encryptor, Error, FileTransfer, Mesh, Ping, Receiver, Scanner, Sender, Signer, Traceroute

Constant Summary collapse

DEFAULT_PORT =

Default port used for communication

5000
VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.decrypt(data, key) ⇒ Object

Helper to decrypt a message



44
45
46
47
# File 'lib/lanet.rb', line 44

def decrypt(data, key)
  result = Encryptor.process_message(data, key)
  result[:content]
end

.encrypt(message, key) ⇒ Object

Helper to encrypt a message



39
40
41
# File 'lib/lanet.rb', line 39

def encrypt(message, key)
  Encryptor.prepare_message(message, key)
end

.file_transfer(port = 5001) ⇒ Object

Add file transfer functionality



54
55
56
# File 'lib/lanet.rb', line 54

def file_transfer(port = 5001)
  FileTransfer.new(port)
end

.mesh_network(port = 5050, max_hops = 10) ⇒ Object

Create a new mesh network instance



59
60
61
# File 'lib/lanet.rb', line 59

def mesh_network(port = 5050, max_hops = 10)
  Mesh.new(port, max_hops)
end

.pinger(timeout: 1, count: 3) ⇒ Object



49
50
51
# File 'lib/lanet.rb', line 49

def pinger(timeout: 1, count: 3)
  Ping.new(timeout: timeout, count: count)
end

.receiver(port = DEFAULT_PORT) ⇒ Object

Creates a new receiver instance



29
30
31
# File 'lib/lanet.rb', line 29

def receiver(port = DEFAULT_PORT)
  Receiver.new(port)
end

.scannerObject

Creates a new scanner instance



34
35
36
# File 'lib/lanet.rb', line 34

def scanner
  Scanner.new
end

.sender(port = DEFAULT_PORT) ⇒ Object

Creates a new sender instance



24
25
26
# File 'lib/lanet.rb', line 24

def sender(port = DEFAULT_PORT)
  Sender.new(port)
end

.traceroute(protocol: :udp, max_hops: 30, timeout: 1, queries: 3) ⇒ Object

Create a new traceroute instance



64
65
66
# File 'lib/lanet.rb', line 64

def traceroute(protocol: :udp, max_hops: 30, timeout: 1, queries: 3)
  Traceroute.new(protocol: protocol, max_hops: max_hops, timeout: timeout, queries: queries)
end