1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the "php-ipfs" package. |
7
|
|
|
* |
8
|
|
|
* (c) Robert Schönthal <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace IPFS\Api; |
15
|
|
|
|
16
|
|
|
use IPFS\Annotation\Api as Endpoint; |
17
|
|
|
use IPFS\Command\Command; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Robert Schönthal <[email protected]> |
21
|
|
|
* @autogenerated |
22
|
|
|
* @codeCoverageIgnore |
23
|
|
|
*/ |
24
|
|
View Code Duplication |
final class P2p implements Api |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Close active p2p listener. |
28
|
|
|
* |
29
|
|
|
* @Endpoint(name="p2p:listener:close") |
30
|
|
|
* |
31
|
|
|
* @param string $arg P2P listener protocol Required: no |
32
|
|
|
* @param bool $all close all listeners |
33
|
|
|
* |
34
|
|
|
* @return Command |
35
|
|
|
*/ |
36
|
|
|
public function listenerClose(string $arg = null, bool $all = false): Command |
37
|
|
|
{ |
38
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* List active p2p listeners. |
43
|
|
|
* |
44
|
|
|
* @Endpoint(name="p2p:listener:ls") |
45
|
|
|
* |
46
|
|
|
* @param bool $headers print table headers (HandlerID, Protocol, Local, Remote) |
47
|
|
|
* |
48
|
|
|
* @return Command |
49
|
|
|
*/ |
50
|
|
|
public function listenerLs(bool $headers = false): Command |
51
|
|
|
{ |
52
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Forward p2p connections to a network multiaddr. |
57
|
|
|
* |
58
|
|
|
* @Endpoint(name="p2p:listener:open") |
59
|
|
|
* |
60
|
|
|
* @param string $arg protocol identifier |
61
|
|
|
* @param string $arg1 request handling application address |
62
|
|
|
* |
63
|
|
|
* @return Command |
64
|
|
|
*/ |
65
|
|
|
public function listenerOpen(string $arg, string $arg1): Command |
66
|
|
|
{ |
67
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Close active p2p stream. |
72
|
|
|
* |
73
|
|
|
* @Endpoint(name="p2p:stream:close") |
74
|
|
|
* |
75
|
|
|
* @param string $arg stream HandlerID Required: no |
76
|
|
|
* @param bool $all close all streams |
77
|
|
|
* |
78
|
|
|
* @return Command |
79
|
|
|
*/ |
80
|
|
|
public function streamClose(string $arg = null, bool $all = false): Command |
81
|
|
|
{ |
82
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Dial to a p2p listener. |
87
|
|
|
* |
88
|
|
|
* @Endpoint(name="p2p:stream:dial") |
89
|
|
|
* |
90
|
|
|
* @param string $arg remote peer to connect to Required: |
91
|
|
|
* @param string $arg1 protocol identifier |
92
|
|
|
* @param string $arg2 address to listen for connection/s (default: /ip4/127 |
93
|
|
|
* |
94
|
|
|
* @return Command |
95
|
|
|
*/ |
96
|
|
|
public function streamDial(string $arg, string $arg1, string $arg2 = null): Command |
97
|
|
|
{ |
98
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* List active p2p streams. |
103
|
|
|
* |
104
|
|
|
* @Endpoint(name="p2p:stream:ls") |
105
|
|
|
* |
106
|
|
|
* @param bool $headers print table headers (HagndlerID, Protocol, Local, Remote) |
107
|
|
|
* |
108
|
|
|
* @return Command |
109
|
|
|
*/ |
110
|
|
|
public function streamLs(bool $headers = false): Command |
111
|
|
|
{ |
112
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.