主要变更: - RDP 远程桌面:新增 backend/pkg/rdp(RDP 引擎 + credssp/display/rle/trace)、 backend/controller/rdp*(连接/凭证/文件/会话/实时)、frontend RDP 组件与 API - Windows SMB 文件传输:backend/pkg/winsmb - 云账单同步:backend/pkg/billingsync + billing_sync/aliyun_billing,前端账单详情 - Agent CLI Kubernetes 工具:kubernetes_action/get、pod_execute/logs - 服务器导入助手:server_import_helpers、ImportCredentialSettings - 国际化与组件重构(cloud/deploy/monitor/server/system 等多模块) - 清理编译产物二进制:移除 backend/server、backend/agent/bin/aiops-agent-* - .gitignore:新增 backend/agent/ 与 .cache/(避免 334MB go-build 缓存误入库) Co-Authored-By: Claude <noreply@anthropic.com>
256 lines
5.0 KiB
Go
256 lines
5.0 KiB
Go
package rle
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
)
|
|
|
|
func decompress1(output *[]uint8, width, height int, input []uint8, size int) bool {
|
|
var (
|
|
prevline, line, count int
|
|
offset, code int
|
|
x int = width
|
|
opcode int
|
|
lastopcode int8 = -1
|
|
insertmix, bicolour, isfillormix bool
|
|
mixmask, mask uint8
|
|
colour1, colour2 uint8
|
|
mix uint8 = 0xff
|
|
fom_mask uint8
|
|
)
|
|
out := *output
|
|
for len(input) != 0 {
|
|
fom_mask = 0
|
|
code = CVAL(&input)
|
|
opcode = code >> 4
|
|
/* Handle different opcode forms */
|
|
switch opcode {
|
|
case 0xc, 0xd, 0xe:
|
|
opcode -= 6
|
|
count = int(code & 0xf)
|
|
offset = 16
|
|
break
|
|
case 0xf:
|
|
opcode = code & 0xf
|
|
if opcode < 9 {
|
|
count = int(CVAL(&input))
|
|
count |= int(CVAL(&input) << 8)
|
|
} else {
|
|
count = 1
|
|
if opcode < 0xb {
|
|
count = 8
|
|
}
|
|
}
|
|
offset = 0
|
|
break
|
|
default:
|
|
opcode >>= 1
|
|
count = int(code & 0x1f)
|
|
offset = 32
|
|
break
|
|
}
|
|
/* Handle strange cases for counts */
|
|
if offset != 0 {
|
|
isfillormix = ((opcode == 2) || (opcode == 7))
|
|
if count == 0 {
|
|
if isfillormix {
|
|
count = int(CVAL(&input)) + 1
|
|
} else {
|
|
count = int(CVAL(&input) + offset)
|
|
}
|
|
} else if isfillormix {
|
|
count <<= 3
|
|
}
|
|
}
|
|
/* Read preliminary data */
|
|
switch opcode {
|
|
case 0: /* Fill */
|
|
if (lastopcode == int8(opcode)) && !((x == width) && (prevline == 0)) {
|
|
insertmix = true
|
|
}
|
|
break
|
|
case 8: /* Bicolour */
|
|
colour1 = uint8(CVAL(&input))
|
|
colour2 = uint8(CVAL(&input))
|
|
break
|
|
case 3: /* Colour */
|
|
colour2 = uint8(CVAL(&input))
|
|
break
|
|
case 6: /* SetMix/Mix */
|
|
fallthrough
|
|
case 7: /* SetMix/FillOrMix */
|
|
mix = uint8(CVAL(&input))
|
|
opcode -= 5
|
|
break
|
|
case 9: /* FillOrMix_1 */
|
|
mask = 0x03
|
|
opcode = 0x02
|
|
fom_mask = 3
|
|
break
|
|
case 0x0a: /* FillOrMix_2 */
|
|
mask = 0x05
|
|
opcode = 0x02
|
|
fom_mask = 5
|
|
break
|
|
}
|
|
lastopcode = int8(opcode)
|
|
mixmask = 0
|
|
/* Output body */
|
|
for count > 0 {
|
|
if x >= width {
|
|
if height <= 0 {
|
|
return false
|
|
}
|
|
|
|
x = 0
|
|
height--
|
|
prevline = line
|
|
line = height * width
|
|
}
|
|
switch opcode {
|
|
case 0: /* Fill */
|
|
if insertmix {
|
|
if prevline == 0 {
|
|
out[x+line] = mix
|
|
} else {
|
|
out[x+line] = out[prevline+x] ^ mix
|
|
}
|
|
insertmix = false
|
|
count--
|
|
x++
|
|
}
|
|
n := min(count, width-x)
|
|
if prevline == 0 {
|
|
clear(out[x+line : x+line+n])
|
|
} else {
|
|
copy(out[x+line:x+line+n], out[prevline+x:prevline+x+n])
|
|
}
|
|
count -= n
|
|
x += n
|
|
break
|
|
case 1: /* Mix */
|
|
n := min(count, width-x)
|
|
if prevline == 0 {
|
|
seg := out[x+line : x+line+n]
|
|
for i := range seg {
|
|
seg[i] = mix
|
|
}
|
|
} else {
|
|
src := out[prevline+x : prevline+x+n]
|
|
dst := out[x+line : x+line+n]
|
|
for i := range dst {
|
|
dst[i] = src[i] ^ mix
|
|
}
|
|
}
|
|
count -= n
|
|
x += n
|
|
break
|
|
case 2: /* Fill or Mix */
|
|
if prevline == 0 {
|
|
for count > 0 && x < width {
|
|
mixmask <<= 1
|
|
if mixmask == 0 {
|
|
mask = fom_mask
|
|
if fom_mask == 0 {
|
|
mask = uint8(CVAL(&input))
|
|
mixmask = 1
|
|
}
|
|
}
|
|
if mask&mixmask != 0 {
|
|
out[x+line] = mix
|
|
} else {
|
|
out[x+line] = 0
|
|
}
|
|
|
|
count--
|
|
x++
|
|
}
|
|
} else {
|
|
for count > 0 && x < width {
|
|
mixmask = mixmask << 1
|
|
if mixmask == 0 {
|
|
mask = fom_mask
|
|
if fom_mask == 0 {
|
|
mask = uint8(CVAL(&input))
|
|
mixmask = 1
|
|
}
|
|
}
|
|
if mask&mixmask != 0 {
|
|
out[x+line] = out[prevline+x] ^ mix
|
|
} else {
|
|
out[x+line] = out[prevline+x]
|
|
}
|
|
|
|
count--
|
|
x++
|
|
}
|
|
}
|
|
break
|
|
case 3: /* Colour */
|
|
n := min(count, width-x)
|
|
seg := out[x+line : x+line+n]
|
|
for i := range seg {
|
|
seg[i] = colour2
|
|
}
|
|
count -= n
|
|
x += n
|
|
break
|
|
case 4: /* Copy */
|
|
for count > 0 && x < width {
|
|
n := min(count, width-x)
|
|
if len(input) < n {
|
|
return false
|
|
}
|
|
copy(out[x+line:x+line+n], input[:n])
|
|
input = input[n:]
|
|
count -= n
|
|
x += n
|
|
}
|
|
break
|
|
case 8: /* Bicolour */
|
|
for count > 0 && x < width {
|
|
if bicolour {
|
|
out[x+line] = colour2
|
|
bicolour = false
|
|
} else {
|
|
out[x+line] = colour1
|
|
bicolour = true
|
|
count++
|
|
}
|
|
|
|
count--
|
|
x++
|
|
}
|
|
|
|
break
|
|
|
|
case 0xd: /* White */
|
|
n := min(count, width-x)
|
|
seg := out[x+line : x+line+n]
|
|
for i := range seg {
|
|
seg[i] = 0xff
|
|
}
|
|
count -= n
|
|
x += n
|
|
break
|
|
case 0xe: /* Black */
|
|
n := min(count, width-x)
|
|
clear(out[x+line : x+line+n])
|
|
count -= n
|
|
x += n
|
|
break
|
|
default:
|
|
fmt.Printf("bitmap opcode 0x%x\n", opcode)
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// decompress2Pool reuses the intermediate []uint16 buffer across calls to
|
|
// decompress2, avoiding a large per-frame allocation.
|
|
var decompress2Pool sync.Pool
|
|
|
|
/* 2 byte bitmap decompress */
|