atomic_p2p.communication package¶
Submodules¶
atomic_p2p.communication.command module¶
-
class
atomic_p2p.communication.command.
Command
(cmd, **kwargs)¶ Bases:
object
-
__init__
(cmd, **kwargs)¶ Init of Command class
- Parameters
cmd (
str
) – unique key for command.
-
_execute
(msg_arr, **kwargs)¶ Implementation of each subclass, this defines how the command actual work
-
_on_command_recv
(msg_arr, **kwargs)¶ Precheck when command is trigger
- Parameters
msg_arr (
list
) – command with arguments split into array.- Return type
str
- Returns
command’s process result. Any exception will cause command annotations been print.
-
atomic_p2p.communication.handler module¶
-
class
atomic_p2p.communication.handler.
Handler
(peer, pkt_type)¶ Bases:
object
Base class for every handler This class responsible for wrapping / handler pkt send and recieve. Including accepted or rejected packet.
The actual data maintain is by Packet class.
-
__init__
(peer, pkt_type)¶ Init of Handler class
- Parameters
peer (Peer) – A Peer object to interact with its inner data.
pkt_type (
str
) – A unique string to represent this pkt in peer when proce- ssing packets.
- Return type
None
-
on_recv
(src, pkt, sock, **kwargs)¶ - Parameters
src (
Tuple
[str
,int
]) – Source host.pkt (
Packet
) – A Packet object contains all data which recieved.sock (SSLSocket) – A SSLSocket object who recv this pkt.
- Return type
None
-
on_recv_pkt
(src, pkt, conn, **kwargs)¶ - Return type
None
-
on_recv_reject_pkt
(src, pkt, conn, **kwargs)¶ - Return type
None
-
pkt_type
¶ - Return type
str
-
post_send
(pkt, sock, **kwargs)¶ - Return type
None
-
pre_send
(pkt, **kwargs)¶ - Return type
None
-
atomic_p2p.communication.packet module¶
-
class
atomic_p2p.communication.packet.
Packet
(dst, src, program_hash, _type, _data)¶ Bases:
object
This class is about how actual information been parse to datas
-
__init__
(dst, src, program_hash, _type, _data)¶ Init of Packet class
- Parameters
dst (
Tuple
[str
,int
]) – Packet is made by who.src (
Tuple
[str
,int
]) – Packet is sending to where.program_hash (
str
) – Sender’s security hash. None means it’s a reject packet need to hide security hash._type (
str
) – Unique handler key to determine packet made by what handler._data (
Dict
[~KT, ~VT]) – A dict object to payload on.
-
data
¶
-
static
deserilize
(raw_data)¶ This is serilizer convert data from utf-8 format string to Packet
- Return type
-
dst
¶
-
export
¶
-
is_reject
()¶ - Return type
bool
-
program_hash
¶
-
redirect_to_host
(src, dst)¶ - Return type
None
-
static
serilize
(obj)¶ - Return type
bytes
-
set_reject
(reject_data, maintain_data=False, maintain_secret=False)¶ - Return type
None
-
src
¶
-
to_dict
()¶ - Return type
Dict
[str
,object
]
-
Module contents¶
-
class
atomic_p2p.communication.
Command
(cmd, **kwargs)¶ Bases:
object
-
__init__
(cmd, **kwargs)¶ Init of Command class
- Parameters
cmd (
str
) – unique key for command.
-
_execute
(msg_arr, **kwargs)¶ Implementation of each subclass, this defines how the command actual work
-
_on_command_recv
(msg_arr, **kwargs)¶ Precheck when command is trigger
- Parameters
msg_arr (
list
) – command with arguments split into array.- Return type
str
- Returns
command’s process result. Any exception will cause command annotations been print.
-
-
class
atomic_p2p.communication.
Handler
(peer, pkt_type)¶ Bases:
object
Base class for every handler This class responsible for wrapping / handler pkt send and recieve. Including accepted or rejected packet.
The actual data maintain is by Packet class.
-
__init__
(peer, pkt_type)¶ Init of Handler class
- Parameters
peer (Peer) – A Peer object to interact with its inner data.
pkt_type (
str
) – A unique string to represent this pkt in peer when proce- ssing packets.
- Return type
None
-
on_recv
(src, pkt, sock, **kwargs)¶ - Parameters
src (
Tuple
[str
,int
]) – Source host.pkt (
Packet
) – A Packet object contains all data which recieved.sock (SSLSocket) – A SSLSocket object who recv this pkt.
- Return type
None
-
on_recv_pkt
(src, pkt, conn, **kwargs)¶ - Return type
None
-
on_recv_reject_pkt
(src, pkt, conn, **kwargs)¶ - Return type
None
-
pkt_type
¶ - Return type
str
-
post_send
(pkt, sock, **kwargs)¶ - Return type
None
-
pre_send
(pkt, **kwargs)¶ - Return type
None
-
-
class
atomic_p2p.communication.
Packet
(dst, src, program_hash, _type, _data)¶ Bases:
object
This class is about how actual information been parse to datas
-
__init__
(dst, src, program_hash, _type, _data)¶ Init of Packet class
- Parameters
dst (
Tuple
[str
,int
]) – Packet is made by who.src (
Tuple
[str
,int
]) – Packet is sending to where.program_hash (
str
) – Sender’s security hash. None means it’s a reject packet need to hide security hash._type (
str
) – Unique handler key to determine packet made by what handler._data (
Dict
[~KT, ~VT]) – A dict object to payload on.
-
data
¶
-
static
deserilize
(raw_data)¶ This is serilizer convert data from utf-8 format string to Packet
- Return type
-
dst
¶
-
export
¶
-
is_reject
()¶ - Return type
bool
-
program_hash
¶
-
redirect_to_host
(src, dst)¶ - Return type
None
-
static
serilize
(obj)¶ - Return type
bytes
-
set_reject
(reject_data, maintain_data=False, maintain_secret=False)¶ - Return type
None
-
src
¶
-
to_dict
()¶ - Return type
Dict
[str
,object
]
-
-
atomic_p2p.communication.
valid_ipv4_format
(address)¶ - Return type
bool
-
atomic_p2p.communication.
valid_ipv6_format
(address)¶ - Return type
bool