Skip to content

Commit d5d3590

Browse files
committed
Resolved all linter errors
1 parent fbbd045 commit d5d3590

File tree

5 files changed

+70
-62
lines changed

5 files changed

+70
-62
lines changed

format/pyrdp/pdu/client_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,5 @@ func decodeFlagsFn(d *decode.D) {
114114
d.FieldBool("reserved2")
115115
d.FieldBool("hidef_rail_supported")
116116

117-
d.SeekRel(int64(d.Pos()) % 31)
117+
d.SeekRel(d.Pos() % 31)
118118
}

format/pyrdp/pdu/clipboard_data.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ func ParseClipboardData(d *decode.D, length int64) {
6060
d.FieldU16("msg_flags", cbFlagsMap)
6161
data_length := d.FieldU32("data_len")
6262

63-
if _, ok := cbParseFnMap[msg_type]; ok {
64-
cbParseFnMap[msg_type].(func(d *decode.D, length uint64))(d, data_length)
65-
return
63+
cbParser, ok := cbParseFnMap[msg_type]
64+
if ok {
65+
parseFn, ok := cbParser.(func(d *decode.D, length uint64))
66+
if ok {
67+
parseFn(d, data_length)
68+
return
69+
}
6670
}
6771
// Assert() once all functions are implemented.
6872
d.FieldRawLen("data", int64(data_length*8))

format/pyrdp/pdu/fastpath_input.go

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,33 @@ const (
2222
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP = 6
2323
)
2424

25-
var eventCodesMap = scalar.UintMapSymStr{
26-
FASTPATH_INPUT_EVENT_SCANCODE: "fastpath_input_event_scancode",
27-
FASTPATH_INPUT_EVENT_MOUSE: "fastpath_input_event_mouse",
28-
FASTPATH_INPUT_EVENT_MOUSEX: "fastpath_input_event_mousex",
29-
FASTPATH_INPUT_EVENT_SYNC: "fastpath_input_event_sync",
30-
FASTPATH_INPUT_EVENT_UNICODE: "fastpath_input_event_unicode",
31-
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: "fastpath_input_event_qoe_timestamp",
32-
}
25+
// commented because unused but we should use one-day
26+
//var eventCodesMap = scalar.UintMapSymStr{
27+
// FASTPATH_INPUT_EVENT_SCANCODE: "fastpath_input_event_scancode",
28+
// FASTPATH_INPUT_EVENT_MOUSE: "fastpath_input_event_mouse",
29+
// FASTPATH_INPUT_EVENT_MOUSEX: "fastpath_input_event_mousex",
30+
// FASTPATH_INPUT_EVENT_SYNC: "fastpath_input_event_sync",
31+
// FASTPATH_INPUT_EVENT_UNICODE: "fastpath_input_event_unicode",
32+
// FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: "fastpath_input_event_qoe_timestamp",
33+
//}
3334

34-
var eventFnMap = map[int]interface{}{
35-
FASTPATH_INPUT_EVENT_SCANCODE: parseFastpathInputEventScancode,
36-
FASTPATH_INPUT_EVENT_MOUSE: parseFastpathInputEventMouse,
37-
FASTPATH_INPUT_EVENT_MOUSEX: parseFastpathInputEventMousex,
38-
FASTPATH_INPUT_EVENT_SYNC: parseFastpathInputEventSync,
39-
FASTPATH_INPUT_EVENT_UNICODE: parseFastpathInputEventUnicode,
40-
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: parseFastpathInputEventQoeTimestamp,
41-
}
35+
//var eventFnMap = map[int]interface{}{
36+
// FASTPATH_INPUT_EVENT_SCANCODE: parseFastpathInputEventScancode,
37+
// FASTPATH_INPUT_EVENT_MOUSE: parseFastpathInputEventMouse,
38+
// FASTPATH_INPUT_EVENT_MOUSEX: parseFastpathInputEventMousex,
39+
// FASTPATH_INPUT_EVENT_SYNC: parseFastpathInputEventSync,
40+
// FASTPATH_INPUT_EVENT_UNICODE: parseFastpathInputEventUnicode,
41+
// FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: parseFastpathInputEventQoeTimestamp,
42+
//}
4243

43-
var fastPathInputEventLengthsMap = map[int]int{
44-
FASTPATH_INPUT_EVENT_SCANCODE: 2,
45-
FASTPATH_INPUT_EVENT_MOUSE: 7,
46-
FASTPATH_INPUT_EVENT_MOUSEX: 7,
47-
FASTPATH_INPUT_EVENT_SYNC: 1,
48-
FASTPATH_INPUT_EVENT_UNICODE: 3,
49-
FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: 5,
50-
}
44+
//var fastPathInputEventLengthsMap = map[int]int{
45+
// FASTPATH_INPUT_EVENT_SCANCODE: 2,
46+
// FASTPATH_INPUT_EVENT_MOUSE: 7,
47+
// FASTPATH_INPUT_EVENT_MOUSEX: 7,
48+
// FASTPATH_INPUT_EVENT_SYNC: 1,
49+
// FASTPATH_INPUT_EVENT_UNICODE: 3,
50+
// FASTPATH_INPUT_EVENT_QOE_TIMESTAMP: 5,
51+
//}
5152

5253
func ParseFastPathInput(d *decode.D, length int64) {
5354
d.FieldStruct("fastpath_input", func(d *decode.D) {
@@ -98,30 +99,31 @@ func ParseFastPathInput(d *decode.D, length int64) {
9899
})
99100
}
100101

101-
func parseFastpathInputEventScancode(d *decode.D) {
102-
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/089d362b-31eb-4a1a-b6fa-92fe61bb5dbf
103-
d.FieldU8("key_code", charMapper)
104-
}
102+
//commented because unused but we should use one-day
103+
//func parseFastpathInputEventScancode(d *decode.D) {
104+
// // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/089d362b-31eb-4a1a-b6fa-92fe61bb5dbf
105+
// d.FieldU8("key_code", CharMapper)
106+
//}
105107

106-
func parseFastpathInputEventMouse(d *decode.D) {
107-
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/16a96ded-b3d3-4468-b993-9c7a51297510
108-
d.FieldU16("pointer_flags", scalar.UintHex)
109-
d.FieldU16("x")
110-
d.FieldU16("y")
111-
}
112-
func parseFastpathInputEventMousex(d *decode.D) {
113-
// https: //docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/2ef7632f-2f2a-4de7-ab58-2585cedcdf48
114-
d.FieldU16("pointer_flags", scalar.UintHex)
115-
d.FieldU16("x")
116-
d.FieldU16("y")
117-
}
118-
func parseFastpathInputEventSync(d *decode.D) {
119-
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/6c5d0ef9-4653-4d69-9ba9-09ba3acd660f
120-
d.FieldU16("padding")
121-
d.FieldU32("toggle_flags")
122-
}
123-
func parseFastpathInputEventUnicode(d *decode.D) {
124-
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/e7b13e98-d800-42bb-9a1d-6948537d2317
125-
d.FieldU16("unicode_code", scalar.UintHex)
126-
}
127-
func parseFastpathInputEventQoeTimestamp(d *decode.D) {}
108+
//func parseFastpathInputEventMouse(d *decode.D) {
109+
// // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/16a96ded-b3d3-4468-b993-9c7a51297510
110+
// d.FieldU16("pointer_flags", scalar.UintHex)
111+
// d.FieldU16("x")
112+
// d.FieldU16("y")
113+
//}
114+
//func parseFastpathInputEventMousex(d *decode.D) {
115+
// // https: //docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/2ef7632f-2f2a-4de7-ab58-2585cedcdf48
116+
// d.FieldU16("pointer_flags", scalar.UintHex)
117+
// d.FieldU16("x")
118+
// d.FieldU16("y")
119+
//}
120+
//func parseFastpathInputEventSync(d *decode.D) {
121+
// // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/6c5d0ef9-4653-4d69-9ba9-09ba3acd660f
122+
// d.FieldU16("padding")
123+
// d.FieldU32("toggle_flags")
124+
//}
125+
//func parseFastpathInputEventUnicode(d *decode.D) {
126+
// // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/e7b13e98-d800-42bb-9a1d-6948537d2317
127+
// d.FieldU16("unicode_code", scalar.UintHex)
128+
//}
129+
//func parseFastpathInputEventQoeTimestamp(d *decode.D) {}

format/pyrdp/pdu/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/wader/fq/pkg/scalar"
1010
)
1111

12-
var charMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
12+
var CharMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
1313
char := s.Actual
1414
s.Sym = fmt.Sprintf("%c", int(char))
1515
return s, nil

format/pyrdp/pyrdp.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,18 @@ func decodePYRDP(d *decode.D) any {
113113
d.FieldU64("timestamp", timestampMapper)
114114
pdu_size := int64(size - 18)
115115

116-
if _, ok := pduParsersMap[pdu_type]; !ok { // catch undeclared parsers
116+
pduParser, ok := pduParsersMap[pdu_type]
117+
if !ok { // catch undeclared parsers
117118
if pdu_size > 0 {
118-
d.FieldRawLen("data", int64(pdu_size*8))
119+
d.FieldRawLen("data", pdu_size*8)
119120
}
120121
return
121122
}
122-
pduParsersMap[uint16(pdu_type)].(func(d *decode.D, length int64))(
123-
d, pdu_size)
123+
parseFn, ok := pduParser.(func(d *decode.D, length int64))
124+
if !ok {
125+
return
126+
}
127+
parseFn(d, pdu_size)
124128

125129
curr := d.Pos() - pos
126130
if READ_EXTRA {
@@ -134,9 +138,7 @@ func decodePYRDP(d *decode.D) any {
134138
return nil
135139
}
136140

137-
func noParse(d *decode.D, length int64) {
138-
return
139-
}
141+
func noParse(d *decode.D, length int64) {}
140142

141143
var timestampMapper = scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
142144
s.Sym = time.UnixMilli(int64(s.Actual)).UTC().String()

0 commit comments

Comments
 (0)