|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace kalanis\RemoteRequest\Protocols\Fsp\Answer; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use kalanis\RemoteRequest\Protocols\Fsp; |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class Version |
|
11
|
|
|
* @package kalanis\RemoteRequest\Protocols\Fsp\Answer |
|
12
|
|
|
* Process FSP version |
|
13
|
|
|
*/ |
|
14
|
|
|
class Version extends AAnswer |
|
15
|
|
|
{ |
|
16
|
|
|
protected string $version = ''; |
|
17
|
|
|
protected ?bool $serverLogs = null; |
|
18
|
|
|
protected ?bool $readOnly = null; |
|
19
|
|
|
protected ?bool $reverseLookup = null; |
|
20
|
|
|
protected ?bool $privateMode = null; |
|
21
|
|
|
protected ?bool $thruControl = null; |
|
22
|
|
|
protected ?bool $acceptExtra = null; |
|
23
|
|
|
protected int $thruMaxAllowed = 0; |
|
24
|
|
|
protected int $thruMaxPayload = 0; |
|
25
|
|
|
|
|
26
|
2 |
|
public function process(): parent |
|
27
|
|
|
{ |
|
28
|
2 |
|
$this->version = substr($this->answer->getContent(), 0, -1); |
|
29
|
2 |
|
$extraSize = $this->answer->getFilePosition(); |
|
30
|
2 |
|
$extraData = $this->answer->getExtraData(); |
|
31
|
2 |
|
if ($extraSize && $extraData) { |
|
32
|
2 |
|
$settings = Fsp\Strings::mb_ord($extraData[0]); |
|
33
|
2 |
|
$this->serverLogs = $this->parseBit($settings, 0b10000000); |
|
34
|
2 |
|
$this->readOnly = $this->parseBit($settings, 0b01000000); |
|
35
|
2 |
|
$this->reverseLookup = $this->parseBit($settings, 0b00100000); |
|
36
|
2 |
|
$this->privateMode = $this->parseBit($settings, 0b00010000); |
|
37
|
2 |
|
$this->thruControl = $this->parseBit($settings, 0b00001000); |
|
38
|
2 |
|
$this->acceptExtra = $this->parseBit($settings, 0b00000100); |
|
39
|
2 |
|
if ($this->thruControl) { |
|
40
|
1 |
|
$this->thruMaxAllowed = Fsp\Strings::mb_ord(substr($extraData, 1, 4)); |
|
41
|
1 |
|
$this->thruMaxPayload = Fsp\Strings::mb_ord(substr($extraData, 5, 2)); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
2 |
|
return $this; |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
2 |
|
protected function parseBit(int $input, int $bitPosition): bool |
|
48
|
|
|
{ |
|
49
|
2 |
|
return boolval($input & $bitPosition); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
2 |
|
public function getVersion(): string |
|
53
|
|
|
{ |
|
54
|
2 |
|
return $this->version; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
2 |
|
public function isServerLogging(): ?bool |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->serverLogs; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
2 |
|
public function isReadOnly(): ?bool |
|
63
|
|
|
{ |
|
64
|
2 |
|
return $this->readOnly; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
2 |
|
public function wantReverseLookup(): ?bool |
|
68
|
|
|
{ |
|
69
|
2 |
|
return $this->reverseLookup; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
2 |
|
public function isPrivateMode(): ?bool |
|
73
|
|
|
{ |
|
74
|
2 |
|
return $this->privateMode; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
2 |
|
public function acceptsExtra(): ?bool |
|
78
|
|
|
{ |
|
79
|
2 |
|
return $this->acceptExtra; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
1 |
|
public function canThruControl(): ?bool |
|
83
|
|
|
{ |
|
84
|
1 |
|
return $this->thruControl; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
public function thruControlMaxAllowed(): int |
|
88
|
|
|
{ |
|
89
|
1 |
|
return $this->thruMaxAllowed; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
1 |
|
public function thruControlMaxPayload(): int |
|
93
|
|
|
{ |
|
94
|
1 |
|
return $this->thruMaxPayload; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|