-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_irc.py
35 lines (26 loc) · 933 Bytes
/
run_irc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from physical_layer.pty import PTY
from link_layer.slip import SLIP
from network_layer.ip import IP
from transport_layer.tcp import TCPServer
from application_layer.irc import IRCServer
def main():
this_end = '192.168.123.2'
other_end = '192.168.123.1'
serial_line = PTY()
link = SLIP({other_end: serial_line})
network = IP(link)
network.define_host_address(this_end)
network.define_routing_table([
('0.0.0.0/0', other_end)
])
tcp_server = TCPServer(network, 7000)
irc_server = IRCServer(tcp_server)
print('To connect to the other end of the physical layer, execute:')
print(' sudo slattach -v -p slip {}'.format(serial_line.pty_name))
print(' sudo ifconfig sl0 {} pointopoint {}'.format(other_end, this_end))
print()
print('Service will be available at address {}'.format(this_end))
print()
irc_server.run()
if __name__ == "__main__":
main()