* refactor go files, add headless telemost support * js crap -> ts crap * docker-build (#32) Co-authored-by: Mimocro <suzumagefag@gmail.com> * add headless telemost for creator app * UX improvements (#39) * Add search in split tunneling app list * Add captcha detection * Add autoclick settings * headless vk joiner * add headless telemost joiner * refactor go modules * redesign settings dialog * headless option in settings * headless joiner support in MainActivity * display headless vk status in statusBar * update ux for headless in creator app * fix double log render for headless mode in creator * unicode for cyrillic * add socks auth * put socksPort inf prefs, verify that port is free on start * proxy only mode * mask addresses in go network errors * update docker build, add file write logic for headless * increment release version, add make-release script --------- Co-authored-by: kulikov <user@Mac.lan> Co-authored-by: Mimocro <67226986+Mimocro@users.noreply.github.com> Co-authored-by: Mimocro <suzumagefag@gmail.com> Co-authored-by: senya <76913432+senya-sh@users.noreply.github.com>
43 lines
1010 B
Go
43 lines
1010 B
Go
package tunnel
|
|
|
|
import "encoding/binary"
|
|
|
|
const (
|
|
MsgConnect byte = 0x01
|
|
MsgConnectOK byte = 0x02
|
|
MsgConnectErr byte = 0x03
|
|
MsgData byte = 0x04
|
|
MsgClose byte = 0x05
|
|
MsgUDP byte = 0x06
|
|
MsgUDPReply byte = 0x07
|
|
)
|
|
|
|
type DataTunnel interface {
|
|
SendData(data []byte)
|
|
SetOnData(fn func([]byte))
|
|
SetOnClose(fn func())
|
|
}
|
|
|
|
func EncodeFrame(connID uint32, msgType byte, payload []byte) []byte {
|
|
buf := make([]byte, 4+5+len(payload))
|
|
binary.BigEndian.PutUint32(buf[0:4], uint32(5+len(payload)))
|
|
binary.BigEndian.PutUint32(buf[4:8], connID)
|
|
buf[8] = msgType
|
|
copy(buf[9:], payload)
|
|
return buf
|
|
}
|
|
|
|
func DecodeFrames(data []byte, cb func(connID uint32, msgType byte, payload []byte)) {
|
|
for len(data) >= 4 {
|
|
frameLen := int(binary.BigEndian.Uint32(data[0:4]))
|
|
if frameLen < 5 || 4+frameLen > len(data) {
|
|
return
|
|
}
|
|
connID := binary.BigEndian.Uint32(data[4:8])
|
|
msgType := data[8]
|
|
payload := data[9 : 4+frameLen]
|
|
cb(connID, msgType, payload)
|
|
data = data[4+frameLen:]
|
|
}
|
|
}
|