Test Failed
Branch master (501ab5)
by Sam
04:58 queued 02:25
created
src/ForwardingServer.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,10 +4,8 @@
 block discarded – undo
4 4
 namespace SamIT\Proxy;
5 5
 
6 6
 
7
-use React\Dns\Resolver\Factory;
8 7
 use React\Dns\Resolver\Resolver;
9 8
 use React\EventLoop\LoopInterface;
10
-use React\Socket\Connection;
11 9
 use React\Stream\Stream;
12 10
 
13 11
 /**
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
 
48 48
         $this->forwarder->forward($incoming, $this->forwardAddress, $this->forwardPort)->then(function(Stream $outgoing) use ($incoming) {
49 49
             $outgoing->on('init', function() use ($outgoing, $incoming) {
50
-               $this->emit('connection', [$incoming, $this->createConnection($outgoing->stream, false)]);
50
+                $this->emit('connection', [$incoming, $this->createConnection($outgoing->stream, false)]);
51 51
             });
52 52
         });
53 53
 
Please login to merge, or discard this patch.
src/Header.php 2 patches
Doc Comments   +20 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         }
71 71
     }
72 72
     /**
73
-     * @return uint16_t
73
+     * @return string|null
74 74
      */
75 75
     protected function getAddressLength()
76 76
     {
@@ -80,6 +80,10 @@  discard block
 block discarded – undo
80 80
 
81 81
     }
82 82
 
83
+    /**
84
+     * @param string $address
85
+     * @param string $protocol
86
+     */
83 87
     protected function encodeAddress($address, $protocol) {
84 88
         if ($this->version == 1) {
85 89
             return $address;
@@ -102,6 +106,11 @@  discard block
 block discarded – undo
102 106
         return $result;
103 107
     }
104 108
 
109
+    /**
110
+     * @param integer $version
111
+     * @param string $address
112
+     * @param string $protocol
113
+     */
105 114
     protected static function decodeAddress($version, $address, $protocol)
106 115
     {
107 116
         if ($version == 1) {
@@ -134,6 +143,10 @@  discard block
 block discarded – undo
134 143
         return $this->encodeAddress($this->sourceAddress, $this->protocol) . ($this->version == 1 ? " " : "") .$this->encodeAddress($this->targetAddress, $this->protocol);
135 144
     }
136 145
 
146
+    /**
147
+     * @param integer $port
148
+     * @param string $protocol
149
+     */
137 150
     protected function encodePort($port, $protocol) {
138 151
         if ($this->version == 1) {
139 152
             return $port;
@@ -241,6 +254,9 @@  discard block
 block discarded – undo
241 254
         }
242 255
     }
243 256
 
257
+    /**
258
+     * @param string $data
259
+     */
244 260
     protected static function parseVersion1($data)
245 261
     {
246 262
         $parts = explode("\x20", $data);
@@ -256,6 +272,9 @@  discard block
 block discarded – undo
256 272
         }
257 273
     }
258 274
 
275
+    /**
276
+     * @param string $data
277
+     */
259 278
     protected static function parseVersion2($data)
260 279
     {
261 280
         $version = ord(substr($data, 12, 1)) >> 4;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function getAddresses()
133 133
     {
134
-        return $this->encodeAddress($this->sourceAddress, $this->protocol) . ($this->version == 1 ? " " : "") .$this->encodeAddress($this->targetAddress, $this->protocol);
134
+        return $this->encodeAddress($this->sourceAddress, $this->protocol) . ($this->version == 1 ? " " : "") . $this->encodeAddress($this->targetAddress, $this->protocol);
135 135
     }
136 136
 
137 137
     protected function encodePort($port, $protocol) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public static function parseHeader(&$data)
222 222
     {
223
-        foreach(self::$signatures as $version => $signature) {
223
+        foreach (self::$signatures as $version => $signature) {
224 224
             // Match.
225 225
             if (strncmp($data, $signature, strlen($signature)) === 0) {
226 226
                 if ($version === 1) {
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
         $protocol = substr($data, 13, 1);
264 264
 
265 265
         $pos = 16;
266
-        $sourceAddress = self::decodeAddress($version, substr($data, $pos, self::$lengths[$protocol] / 2  - 2), $protocol);
267
-        $pos += self::$lengths[$protocol] / 2  - 2;
268
-        $targetAddress = self::decodeAddress($version, substr($data, $pos, self::$lengths[$protocol] / 2  - 2), $protocol);
269
-        $pos += self::$lengths[$protocol] / 2  - 2;
266
+        $sourceAddress = self::decodeAddress($version, substr($data, $pos, self::$lengths[$protocol] / 2 - 2), $protocol);
267
+        $pos += self::$lengths[$protocol] / 2 - 2;
268
+        $targetAddress = self::decodeAddress($version, substr($data, $pos, self::$lengths[$protocol] / 2 - 2), $protocol);
269
+        $pos += self::$lengths[$protocol] / 2 - 2;
270 270
         $sourcePort = unpack('n', substr($data, $pos, 2))[1];
271 271
         $targetPort = unpack('n', substr($data, $pos + 2, 2))[1];
272 272
 
Please login to merge, or discard this patch.
src/PortConnection.php 1 patch
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     /**
52
-     * @param $address
52
+     * @param string $address
53 53
      * @return string
54 54
      * @todo Make parent function protected.
55 55
      */
@@ -58,6 +58,9 @@  discard block
 block discarded – undo
58 58
         return trim(substr($address, 0, strrpos($address, ':')), '[]');
59 59
     }
60 60
 
61
+    /**
62
+     * @param string $address
63
+     */
61 64
     protected function parsePort($address)
62 65
     {
63 66
         return end($parts = explode(':', $address));
Please login to merge, or discard this patch.
src/Server.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 namespace SamIT\Proxy;
5 5
 
6 6
 
7
-use React\Dns\Resolver\Factory;
8 7
 use React\Dns\Resolver\Resolver;
9 8
 use React\EventLoop\LoopInterface;
10 9
 
Please login to merge, or discard this patch.