sendLogin
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Mihai Moldovanu 2022-03-23 03:23:48 +02:00
parent 74f66ffce2
commit ddec70f4d7

View File

@ -5,29 +5,25 @@ import (
"net"
)
/* login to El */
/* Login to El */
func sendLogin(c net.Conn, user string, password string) {
s := user + " " + password
lungime := len(s) + 3
b := make([]byte, lungime+2)
length := len(s) + 3
b := make([]byte, length+2)
b[0] = 140
b[1] = byte(lungime % 256)
b[2] = byte(lungime / 256)
b[1] = byte(length % 256)
b[2] = byte(length / 256)
copy(b[3:], s)
b[lungime+1] = 0
b[length+1] = 0
binary.Write(c, binary.LittleEndian, b)
}
/* Send back to server what we received */
func sendPingReply(c net.Conn, b []byte) {
ping_reply := make([]byte, 7)
ping_reply[0] = b[0]
ping_reply[1] = b[1]
ping_reply[2] = b[2]
ping_reply[3] = b[3]
ping_reply[4] = b[4]
ping_reply[5] = b[5]
ping_reply[6] = b[6]
for i := 0; i < 7; i++ {
ping_reply[i] = b[i]
}
binary.Write(c, binary.LittleEndian, ping_reply)
}