-
Notifications
You must be signed in to change notification settings - Fork 9
/
get_update.go
60 lines (47 loc) · 1.04 KB
/
get_update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package rdp
import (
"errors"
"fmt"
"log"
"github.com/kulaginds/rdp-html5/internal/pkg/rdp/fastpath"
"github.com/kulaginds/rdp-html5/internal/pkg/rdp/pdu"
)
func (c *client) GetUpdate() (*fastpath.UpdatePDU, error) {
protocol, err := receiveProtocol(c.buffReader)
if err != nil {
return nil, err
}
if protocol.IsX224() {
err = c.getX224Update()
switch {
case err == nil: // pass
case errors.Is(err, pdu.ErrDeactiateAll):
return nil, err
default:
return nil, fmt.Errorf("get X.224 update: %w", err)
}
return c.GetUpdate()
}
return c.fastPath.Receive()
}
func (c *client) getX224Update() error {
channelID, wire, err := c.mcsLayer.Receive()
if err != nil {
return err
}
if channelID == c.channelIDMap["rail"] {
err = c.handleRail(wire)
if err != nil {
return err
}
return nil
}
var data pdu.Data
if err = data.Deserialize(wire); err != nil {
return err
}
if data.ShareDataHeader.PDUType2.IsErrorInfo() {
log.Printf("received error info: %s\n", data.ErrorInfoPDUData.String())
}
return nil
}