1
1
mirror of https://github.com/wader/fq.git synced 2024-09-11 20:07:11 +03:00

Resolved all linter errors

This commit is contained in:
Olivier Bilodeau 2024-06-13 16:02:57 -04:00 committed by Mattias Wadman
parent f5471adb4f
commit 6caa7fa78b
5 changed files with 70 additions and 62 deletions

View File

@ -114,5 +114,5 @@ func decodeFlagsFn(d *decode.D) {
d.FieldBool("reserved2") d.FieldBool("reserved2")
d.FieldBool("hidef_rail_supported") d.FieldBool("hidef_rail_supported")
d.SeekRel(int64(d.Pos()) % 31) d.SeekRel(d.Pos() % 31)
} }

View File

@ -60,9 +60,13 @@ func ParseClipboardData(d *decode.D, length int64) {
d.FieldU16("msg_flags", cbFlagsMap) d.FieldU16("msg_flags", cbFlagsMap)
data_length := d.FieldU32("data_len") data_length := d.FieldU32("data_len")
if _, ok := cbParseFnMap[msg_type]; ok { cbParser, ok := cbParseFnMap[msg_type]
cbParseFnMap[msg_type].(func(d *decode.D, length uint64))(d, data_length) if ok {
return parseFn, ok := cbParser.(func(d *decode.D, length uint64))
if ok {
parseFn(d, data_length)
return
}
} }
// Assert() once all functions are implemented. // Assert() once all functions are implemented.
d.FieldRawLen("data", int64(data_length*8)) d.FieldRawLen("data", int64(data_length*8))

View File

@ -22,32 +22,33 @@ const (
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP = 6 FASTPATH_INPUT_EVENT_QOE_TIMESTAMP = 6
) )
var eventCodesMap = scalar.UintMapSymStr{ // commented because unused but we should use one-day
FASTPATH_INPUT_EVENT_SCANCODE: "fastpath_input_event_scancode", //var eventCodesMap = scalar.UintMapSymStr{
FASTPATH_INPUT_EVENT_MOUSE: "fastpath_input_event_mouse", // FASTPATH_INPUT_EVENT_SCANCODE: "fastpath_input_event_scancode",
FASTPATH_INPUT_EVENT_MOUSEX: "fastpath_input_event_mousex", // FASTPATH_INPUT_EVENT_MOUSE: "fastpath_input_event_mouse",
FASTPATH_INPUT_EVENT_SYNC: "fastpath_input_event_sync", // FASTPATH_INPUT_EVENT_MOUSEX: "fastpath_input_event_mousex",
FASTPATH_INPUT_EVENT_UNICODE: "fastpath_input_event_unicode", // FASTPATH_INPUT_EVENT_SYNC: "fastpath_input_event_sync",
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: "fastpath_input_event_qoe_timestamp", // FASTPATH_INPUT_EVENT_UNICODE: "fastpath_input_event_unicode",
} // FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: "fastpath_input_event_qoe_timestamp",
//}
var eventFnMap = map[int]interface{}{ //var eventFnMap = map[int]interface{}{
FASTPATH_INPUT_EVENT_SCANCODE: parseFastpathInputEventScancode, // FASTPATH_INPUT_EVENT_SCANCODE: parseFastpathInputEventScancode,
FASTPATH_INPUT_EVENT_MOUSE: parseFastpathInputEventMouse, // FASTPATH_INPUT_EVENT_MOUSE: parseFastpathInputEventMouse,
FASTPATH_INPUT_EVENT_MOUSEX: parseFastpathInputEventMousex, // FASTPATH_INPUT_EVENT_MOUSEX: parseFastpathInputEventMousex,
FASTPATH_INPUT_EVENT_SYNC: parseFastpathInputEventSync, // FASTPATH_INPUT_EVENT_SYNC: parseFastpathInputEventSync,
FASTPATH_INPUT_EVENT_UNICODE: parseFastpathInputEventUnicode, // FASTPATH_INPUT_EVENT_UNICODE: parseFastpathInputEventUnicode,
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: parseFastpathInputEventQoeTimestamp, // FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: parseFastpathInputEventQoeTimestamp,
} //}
var fastPathInputEventLengthsMap = map[int]int{ //var fastPathInputEventLengthsMap = map[int]int{
FASTPATH_INPUT_EVENT_SCANCODE: 2, // FASTPATH_INPUT_EVENT_SCANCODE: 2,
FASTPATH_INPUT_EVENT_MOUSE: 7, // FASTPATH_INPUT_EVENT_MOUSE: 7,
FASTPATH_INPUT_EVENT_MOUSEX: 7, // FASTPATH_INPUT_EVENT_MOUSEX: 7,
FASTPATH_INPUT_EVENT_SYNC: 1, // FASTPATH_INPUT_EVENT_SYNC: 1,
FASTPATH_INPUT_EVENT_UNICODE: 3, // FASTPATH_INPUT_EVENT_UNICODE: 3,
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: 5, // FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: 5,
} //}
func ParseFastPathInput(d *decode.D, length int64) { func ParseFastPathInput(d *decode.D, length int64) {
d.FieldStruct("fastpath_input", func(d *decode.D) { d.FieldStruct("fastpath_input", func(d *decode.D) {
@ -98,30 +99,31 @@ func ParseFastPathInput(d *decode.D, length int64) {
}) })
} }
func parseFastpathInputEventScancode(d *decode.D) { //commented because unused but we should use one-day
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/089d362b-31eb-4a1a-b6fa-92fe61bb5dbf //func parseFastpathInputEventScancode(d *decode.D) {
d.FieldU8("key_code", charMapper) // // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/089d362b-31eb-4a1a-b6fa-92fe61bb5dbf
} // d.FieldU8("key_code", CharMapper)
//}
func parseFastpathInputEventMouse(d *decode.D) { //func parseFastpathInputEventMouse(d *decode.D) {
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/16a96ded-b3d3-4468-b993-9c7a51297510 // // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/16a96ded-b3d3-4468-b993-9c7a51297510
d.FieldU16("pointer_flags", scalar.UintHex) // d.FieldU16("pointer_flags", scalar.UintHex)
d.FieldU16("x") // d.FieldU16("x")
d.FieldU16("y") // d.FieldU16("y")
} //}
func parseFastpathInputEventMousex(d *decode.D) { //func parseFastpathInputEventMousex(d *decode.D) {
// https: //docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/2ef7632f-2f2a-4de7-ab58-2585cedcdf48 // // https: //docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/2ef7632f-2f2a-4de7-ab58-2585cedcdf48
d.FieldU16("pointer_flags", scalar.UintHex) // d.FieldU16("pointer_flags", scalar.UintHex)
d.FieldU16("x") // d.FieldU16("x")
d.FieldU16("y") // d.FieldU16("y")
} //}
func parseFastpathInputEventSync(d *decode.D) { //func parseFastpathInputEventSync(d *decode.D) {
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/6c5d0ef9-4653-4d69-9ba9-09ba3acd660f // // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/6c5d0ef9-4653-4d69-9ba9-09ba3acd660f
d.FieldU16("padding") // d.FieldU16("padding")
d.FieldU32("toggle_flags") // d.FieldU32("toggle_flags")
} //}
func parseFastpathInputEventUnicode(d *decode.D) { //func parseFastpathInputEventUnicode(d *decode.D) {
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/e7b13e98-d800-42bb-9a1d-6948537d2317 // // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/e7b13e98-d800-42bb-9a1d-6948537d2317
d.FieldU16("unicode_code", scalar.UintHex) // d.FieldU16("unicode_code", scalar.UintHex)
} //}
func parseFastpathInputEventQoeTimestamp(d *decode.D) {} //func parseFastpathInputEventQoeTimestamp(d *decode.D) {}

View File

@ -9,7 +9,7 @@ import (
"github.com/wader/fq/pkg/scalar" "github.com/wader/fq/pkg/scalar"
) )
var charMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) { var CharMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
char := s.Actual char := s.Actual
s.Sym = fmt.Sprintf("%c", int(char)) s.Sym = fmt.Sprintf("%c", int(char))
return s, nil return s, nil

View File

@ -113,14 +113,18 @@ func decodePYRDP(d *decode.D) any {
d.FieldU64("timestamp", timestampMapper) d.FieldU64("timestamp", timestampMapper)
pdu_size := int64(size - 18) pdu_size := int64(size - 18)
if _, ok := pduParsersMap[pdu_type]; !ok { // catch undeclared parsers pduParser, ok := pduParsersMap[pdu_type]
if !ok { // catch undeclared parsers
if pdu_size > 0 { if pdu_size > 0 {
d.FieldRawLen("data", int64(pdu_size*8)) d.FieldRawLen("data", pdu_size*8)
} }
return return
} }
pduParsersMap[uint16(pdu_type)].(func(d *decode.D, length int64))( parseFn, ok := pduParser.(func(d *decode.D, length int64))
d, pdu_size) if !ok {
return
}
parseFn(d, pdu_size)
curr := d.Pos() - pos curr := d.Pos() - pos
if READ_EXTRA { if READ_EXTRA {
@ -134,9 +138,7 @@ func decodePYRDP(d *decode.D) any {
return nil return nil
} }
func noParse(d *decode.D, length int64) { func noParse(d *decode.D, length int64) {}
return
}
var timestampMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) { var timestampMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
s.Sym = time.UnixMilli(int64(s.Actual)).UTC().String() s.Sym = time.UnixMilli(int64(s.Actual)).UTC().String()