|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the wow-apps/symfony-proxybonanza project |
|
4
|
|
|
* https://github.com/wow-apps/symfony-proxybonanza |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2016 WoW-Apps |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WowApps\ProxybonanzaBundle\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
19
|
|
|
use WowApps\ProxybonanzaBundle\Entity\Plan; |
|
20
|
|
|
use WowApps\ProxybonanzaBundle\Entity\Proxy; |
|
21
|
|
|
use WowApps\ProxybonanzaBundle\Service\ProxyBonanza; |
|
22
|
|
|
use WowApps\ProxybonanzaBundle\Traits\HelperTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class ProxybonanzaListCommand |
|
26
|
|
|
* @author Alexey Samara <[email protected]> |
|
27
|
|
|
* @package wow-apps/symfony-proxybonanza |
|
28
|
|
|
*/ |
|
29
|
|
|
class ProxybonanzaListCommand extends ContainerAwareCommand |
|
30
|
|
|
{ |
|
31
|
|
|
use HelperTrait; |
|
32
|
|
|
|
|
33
|
|
|
const ALLOWED_OPTION_SHOW = ['all', 'remote', 'local']; |
|
34
|
|
|
|
|
35
|
|
|
protected function configure() |
|
36
|
|
|
{ |
|
37
|
|
|
$this |
|
38
|
|
|
->setName('wowapps:proxybonanza:list') |
|
39
|
|
|
->setDescription('Show\'s list of proxies') |
|
40
|
|
|
->addOption('show', null, InputOption::VALUE_OPTIONAL, 'Show all | remote | local') |
|
41
|
|
|
; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param InputInterface $input |
|
46
|
|
|
* @param OutputInterface $output |
|
47
|
|
|
* @return int|null|void |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
50
|
|
|
{ |
|
51
|
|
|
$timeStart = microtime(true); |
|
52
|
|
|
$listShow = 'all'; |
|
53
|
|
|
|
|
54
|
|
|
$symfonyStyle = new SymfonyStyle($input, $output); |
|
55
|
|
|
|
|
56
|
|
|
/** @var ProxyBonanza $proxyBonanza */ |
|
57
|
|
|
$proxyBonanza = $this->getContainer()->get('wowapps.proxybonanza'); |
|
58
|
|
|
|
|
59
|
|
|
$symfonyStyle->title(' P R O X Y B O N A N Z A L I S T '); |
|
60
|
|
|
|
|
61
|
|
|
if ($input->getOption('show') && in_array(strtolower($input->getOption('show')), self::ALLOWED_OPTION_SHOW)) { |
|
62
|
|
|
$listShow = strtolower($input->getOption('show')); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if ($listShow == 'all' || $listShow == 'local') { |
|
66
|
|
|
$symfonyStyle->section(' List of local proxies: '); |
|
67
|
|
|
|
|
68
|
|
|
$pbPlans = $proxyBonanza->getLocalPlans(); |
|
69
|
|
|
$pbPlans = $proxyBonanza->getLocalPlansProxies($pbPlans); |
|
70
|
|
|
|
|
71
|
|
|
$header = ['ip', 'http port', 'socks port', 'login', 'password', 'region']; |
|
72
|
|
|
|
|
73
|
|
|
$body = []; |
|
74
|
|
|
|
|
75
|
|
|
/** @var Plan $pbPlan */ |
|
76
|
|
|
foreach ($pbPlans as $pbPlan) { |
|
77
|
|
|
$symfonyStyle->text(sprintf(' Proxy plan #%d local proxies:', $pbPlan->getId())); |
|
78
|
|
|
|
|
79
|
|
|
/** @var Proxy $proxy */ |
|
80
|
|
|
foreach ($pbPlan->getProxy() as $proxy) { |
|
81
|
|
|
$body[] = [ |
|
82
|
|
|
$proxy->getProxyIp(), |
|
83
|
|
|
$proxy->getProxyPortHttp(), |
|
84
|
|
|
$proxy->getProxyPortSocks(), |
|
85
|
|
|
$proxy->getPlan()->getLogin(), |
|
86
|
|
|
$proxy->getPlan()->getPassword(), |
|
87
|
|
|
$proxy->getProxyRegionCountryName() |
|
88
|
|
|
]; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
$symfonyStyle->table($header, $body); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
if ($listShow == 'all' || $listShow == 'remote') { |
|
96
|
|
|
$symfonyStyle->section(' List of remote proxies: '); |
|
97
|
|
|
|
|
98
|
|
|
$pbPlans = $proxyBonanza->getRemotePlans(); |
|
99
|
|
|
$pbPlans = $proxyBonanza->getRemotePacks($pbPlans); |
|
100
|
|
|
|
|
101
|
|
|
$header = ['ip', 'http port', 'socks port', 'login', 'password', 'region']; |
|
102
|
|
|
|
|
103
|
|
|
$body = []; |
|
104
|
|
|
|
|
105
|
|
|
/** @var Plan $pbPlan */ |
|
106
|
|
|
foreach ($pbPlans as $pbPlan) { |
|
107
|
|
|
$symfonyStyle->text(sprintf(' Proxy plan #%d remote proxies:', $pbPlan->getId())); |
|
108
|
|
|
|
|
109
|
|
|
/** @var Proxy $proxy */ |
|
110
|
|
|
foreach ($pbPlan->getProxy() as $proxy) { |
|
111
|
|
|
$body[] = [ |
|
112
|
|
|
$proxy->getProxyId(), |
|
113
|
|
|
$proxy->getProxyPortHttp(), |
|
114
|
|
|
$proxy->getProxyPortSocks(), |
|
115
|
|
|
$proxy->getPlan()->getLogin(), |
|
116
|
|
|
$proxy->getPlan()->getPassword(), |
|
117
|
|
|
$proxy->getProxyRegionCountryName() |
|
118
|
|
|
]; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
$symfonyStyle->table($header, $body); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
$symfonyStyle->note(sprintf('Command is executed in %s seconds', $this->formatSpentTime($timeStart))); |
|
126
|
|
|
|
|
127
|
|
|
$symfonyStyle->newLine(2); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|