Fix write
This commit is contained in:
parent
7e3892a947
commit
844bb00dd5
2 changed files with 4 additions and 3 deletions
|
@ -2,8 +2,7 @@ IP-туннель (VPN) с tun-интерфейсом на Python
|
|||
============================================
|
||||
|
||||
Данный код был написан в рамках трансляции
|
||||
(https://www.youtube.com/watch?v=tgXV1h_YMu4)
|
||||
и будет доработан позже.
|
||||
(https://www.youtube.com/watch?v=tgXV1h_YMu4).
|
||||
|
||||
|
||||
|
||||
|
|
4
main.py
4
main.py
|
@ -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))
|
||||
|
|
Reference in a new issue