#why I got packet loss in my created vpn protocol

3 messages · Page 1 of 1 (latest)

bleak orchid
#

then in the server when I receive the packets I write them to tun0 interface that I created and I also already set up NAT rules to send this pakcets that I write to tun0 to the internet with src ip of my server, then when the response packet of the sent packet comes, it sends it back to tun0 and from the local ip of the packet I find the corresponding user tcp connection and write the response packet to the user connection.

code that handles reading packets from client connection and send them to tun0, hence to the internet

    var totalBytes int
    for {

        n, _ := conn.Read(buf)
        totalBytes += n
        fmt.Println(totalBytes / 1000)
        packets := extractIPPackets(buf[:n])
        // pkt, err := decrypt(session.SharedKey, buf[:n])
        // if err != nil {
        //     continue
        // }

        for _, p := range packets {
            go server.TunnelInterface.Write(p)

        }

    }```
#

sss

#

it does not let me complete wtf