1
0
Fork 0
master
Alex Kotov 3 years ago
parent 7e3892a947
commit 844bb00dd5
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
  1. 3
      README.md
  2. 4
      main.py

@ -2,8 +2,7 @@ IP-туннель (VPN) с tun-интерфейсом на Python
============================================
Данный код был написан в рамках трансляции
(https://www.youtube.com/watch?v=tgXV1h_YMu4)
и будет доработан позже.
(https://www.youtube.com/watch?v=tgXV1h_YMu4).

@ -175,7 +175,9 @@ def handle_ip_packet(ip_packet, conn, tun_iface, config):
if ip_packet.header.dst == config.iface_addr:
print('sending to tun iface')
buf = b'\x00\x00' + IP_V4_PROTO + ip_packet_packed
tun_iface.write(buf)
while len(buf):
nbytes = tun_iface.write(buf)
buf = buf[nbytes:]
elif ip_packet.header.dst == config.iface_dstaddr:
print('sending to remote peer')
ip_packet_length = struct.pack('>I', len(ip_packet_packed))