mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Feat: return proxy support
This commit is contained in:
parent
55506d6ec1
commit
7eab19371e
@ -27,6 +27,12 @@ TELEGRAM_API_HASH=
|
|||||||
# FATAL_ERROR = 0; ERROR = 1; WARNING = 2; const NOTICE = 3; VERBOSE = 4; ULTRA_VERBOSE = 5;
|
# FATAL_ERROR = 0; ERROR = 1; WARNING = 2; const NOTICE = 3; VERBOSE = 4; ULTRA_VERBOSE = 5;
|
||||||
LOGGER_LEVEL=2
|
LOGGER_LEVEL=2
|
||||||
|
|
||||||
|
# TELEGRAM SOCKS5 PROXY (optional)
|
||||||
|
TELEGRAM_PROXY_ADDRESS=
|
||||||
|
TELEGRAM_PROXY_PORT=
|
||||||
|
TELEGRAM_PROXY_USERNAME=
|
||||||
|
TELEGRAM_PROXY_PASSWORD=
|
||||||
|
|
||||||
# DB
|
# DB
|
||||||
# memory
|
# memory
|
||||||
# Keep all data in memory/session file.
|
# Keep all data in memory/session file.
|
||||||
|
@ -26,6 +26,12 @@ TELEGRAM_API_HASH=
|
|||||||
# FATAL_ERROR = 0; ERROR = 1; WARNING = 2; const NOTICE = 3; VERBOSE = 4; ULTRA_VERBOSE = 5;
|
# FATAL_ERROR = 0; ERROR = 1; WARNING = 2; const NOTICE = 3; VERBOSE = 4; ULTRA_VERBOSE = 5;
|
||||||
LOGGER_LEVEL=2
|
LOGGER_LEVEL=2
|
||||||
|
|
||||||
|
# TELEGRAM SOCKS5 PROXY (optional)
|
||||||
|
TELEGRAM_PROXY_ADDRESS=
|
||||||
|
TELEGRAM_PROXY_PORT=
|
||||||
|
TELEGRAM_PROXY_USERNAME=
|
||||||
|
TELEGRAM_PROXY_PASSWORD=
|
||||||
|
|
||||||
# DB
|
# DB
|
||||||
# memory
|
# memory
|
||||||
# Keep all data in memory/session file.
|
# Keep all data in memory/session file.
|
||||||
|
27
README.md
27
README.md
@ -232,15 +232,24 @@ Each session stored in `sessions/{$session}.madeline`. Nested folders supported.
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"connection_settings": {
|
"connection": {
|
||||||
"all": {
|
"proxies": {
|
||||||
"proxy": "\\SocksProxy",
|
"\\danog\\MadelineProto\\Stream\\Proxy\\SocksProxy": [
|
||||||
"proxy_extra": {
|
{
|
||||||
"address": "127.0.0.1",
|
"address": "127.0.0.1",
|
||||||
"port": 1234,
|
"port": 1234,
|
||||||
"username": "user",
|
"username": "user",
|
||||||
"password": "pass"
|
"password": "pass"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"\\danog\\MadelineProto\\Stream\\Proxy\\HttpProxy": [
|
||||||
|
{
|
||||||
|
"address": "127.0.0.1",
|
||||||
|
"port": 1234,
|
||||||
|
"username": "user",
|
||||||
|
"password": "pass"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
config.php
16
config.php
@ -23,7 +23,17 @@ $settings = [
|
|||||||
'rpc_drop_timeout' => 11,
|
'rpc_drop_timeout' => 11,
|
||||||
],
|
],
|
||||||
'connection' => [
|
'connection' => [
|
||||||
'max_media_socket_count' => 10
|
'max_media_socket_count' => 10,
|
||||||
|
'proxies' => [
|
||||||
|
'\danog\MadelineProto\Stream\Proxy\SocksProxy' => [
|
||||||
|
[
|
||||||
|
"address" => (string)getenv('TELEGRAM_PROXY_ADDRESS'),
|
||||||
|
"port"=> (int)getenv('TELEGRAM_PROXY_PORT'),
|
||||||
|
"username"=> (string)getenv('TELEGRAM_PROXY_USERNAME'),
|
||||||
|
"password"=> (string)getenv('TELEGRAM_PROXY_PASSWORD'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
],
|
],
|
||||||
'serialization' => [
|
'serialization' => [
|
||||||
'interval' => 600,
|
'interval' => 600,
|
||||||
@ -63,6 +73,10 @@ $settings = [
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (empty($settings['telegram']['connection']['proxies']['\danog\MadelineProto\Stream\Proxy\SocksProxy'][0]['address'])) {
|
||||||
|
$settings['telegram']['connection']['proxies'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($settings['telegram']['app_info']['api_id'])) {
|
if (empty($settings['telegram']['app_info']['api_id'])) {
|
||||||
throw new InvalidArgumentException('Need to fill TELEGRAM_API_ID in .env.docker or .env');
|
throw new InvalidArgumentException('Need to fill TELEGRAM_API_ID in .env.docker or .env');
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ class Client
|
|||||||
|
|
||||||
private static function getSettingsFromArray(string $session, array $settings, SettingsAbstract $settingsObject = new Settings()): SettingsAbstract {
|
private static function getSettingsFromArray(string $session, array $settings, SettingsAbstract $settingsObject = new Settings()): SettingsAbstract {
|
||||||
foreach ($settings as $key => $value) {
|
foreach ($settings as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value) && $key !== 'proxies') {
|
||||||
if ($key === 'db' && isset($value['type'])) {
|
if ($key === 'db' && isset($value['type'])) {
|
||||||
$type = match ($value['type']) {
|
$type = match ($value['type']) {
|
||||||
'memory' => new Settings\Database\Memory(),
|
'memory' => new Settings\Database\Memory(),
|
||||||
|
Loading…
Reference in New Issue
Block a user