Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mtproto_proxy
Commits
a9701a3a
Unverified
Commit
a9701a3a
authored
Jun 08, 2019
by
Sergey Prokhorov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into multiplexing
parents
22325843
69d5a18e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
README.md
README.md
+5
-4
mtproto_proxy.app.src
src/mtproto_proxy.app.src
+1
-1
start.sh
start.sh
+22
-8
No files found.
README.md
View file @
a9701a3a
...
...
@@ -43,9 +43,10 @@ docker run -d --network=host -e MTP_PORT=443 -e MTP_SECRET=d0d6e111bada5511fcce9
Where
*
`-p 443`
/
`MTP_PORT`
proxy port
*
`-s d0d6e111bada5511fcce9584deadbeef`
/
`MTP_SECRET`
proxy secret (don't append
`dd`
! it should be 32 chars long!)
*
`-t dcbe8f1493fa4cd9ab300891c0b5b326`
/
`MTP_TAG`
ad-tag that you get from
[
@MTProxybot
](
https://t.me/MTProxybot
)
*
`-p 443`
/
`MTP_PORT=…`
proxy port
*
`-s d0d6e111bada5511fcce9584deadbeef`
/
`MTP_SECRET=…`
proxy secret (don't append
`dd`
! it should be 32 chars long!)
*
`-t dcbe8f1493fa4cd9ab300891c0b5b326`
/
`MTP_TAG=…`
ad-tag that you get from
[
@MTProxybot
](
https://t.me/MTProxybot
)
*
`-d`
/
`MTP_DD_ONLY=t`
only allow "secure" connections (dd-secrets)
### To run with custom config-file
...
...
@@ -274,6 +275,6 @@ Helpers
Number of connections
```
erlang
```
bash
/opt/mtp_proxy/bin/mtp_proxy
eval
'lists:sum([proplists:get_value(all_connections, L) || {_, L} <- ranch:info()]).'
```
src/mtproto_proxy.app.src
View file @
a9701a3a
...
...
@@ -30,7 +30,7 @@
%% `ip_lookup_services' will be tried one-by-one: if 1st is not responding,
%% 2nd one will be tried and so on
{ip_lookup_services,
["http://ip.seriyps.ru/",
["http://ip
v4
.seriyps.ru/",
"https://digitalresistance.dog/myIp",
"http://ipv4.myexternalip.com/raw"]},
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
...
...
start.sh
View file @
a9701a3a
...
...
@@ -2,6 +2,7 @@
# Script that helps to overwrite port/secret/ad tag from command line without changing config-files
CMD
=
"/opt/mtp_proxy/bin/mtp_proxy foreground"
# CMD="/opt/mtp_proxy/bin/mtp_proxy console"
THIS
=
$0
usage
()
{
...
...
@@ -10,13 +11,16 @@ usage() {
echo
"
${
THIS
}
"
echo
"To start in single-port mode configured from command-line:"
echo
"
${
THIS
}
-p <port> -s <secret> -t <ad tag>"
echo
"To only allow connections with randomized protocol (dd-secrets):"
echo
"
${
THIS
}
-d"
echo
"Parameters:"
echo
"-p <port>: port to listen on. 1-65535"
echo
"-s <secret>: proxy secret. 32 hex characters 0-9 a-f"
echo
"-t <ad tag>: promo tag, that you get from @MTProxybot. 32 hex characters"
echo
"port secret and tag can also be configured via environment variables:"
echo
"MTP_PORT, MTP_SECRET, MTP_TAG"
echo
"If both command line and environment are set, command line have higher priority"
echo
"-t <ad tag>: promo tag that you get from @MTProxybot. 32 hex characters"
echo
"-d: only allow 'secure' connections (with dd-secret)"
echo
"port, secret, tag and secure mode can also be configured via environment variables:"
echo
"MTP_PORT, MTP_SECRET, MTP_TAG, MTP_DD_ONLY"
echo
"If both command line and environment are set, command line have higher priority."
}
error
()
{
...
...
@@ -29,9 +33,10 @@ error() {
PORT
=
${
MTP_PORT
:-
""
}
SECRET
=
${
MTP_SECRET
:-
""
}
TAG
=
${
MTP_TAG
:-
""
}
DD_ONLY
=
${
MTP_DD_ONLY
:-
""
}
# check command line options
while
getopts
"p:s:t:h"
o
;
do
while
getopts
"p:s:t:
d
h"
o
;
do
case
"
${
o
}
"
in
p
)
PORT
=
${
OPTARG
}
...
...
@@ -42,16 +47,25 @@ while getopts "p:s:t:h" o; do
t
)
TAG
=
${
OPTARG
}
;;
d
)
DD_ONLY
=
"y"
;;
h
)
usage
exit
0
esac
done
DD_ARG
=
""
if
[
-n
"
${
DD_ONLY
}
"
]
;
then
DD_ARG
=
'-mtproto_proxy allowed_protocols [mtp_secure]'
fi
# if at least one option is set...
if
[
-n
"
${
PORT
}
"
-o
-n
"
${
SECRET
}
"
-o
-n
"
${
TAG
}
"
]
;
then
# If at least one of them not set...
[
-z
"
${
PORT
}
"
-o
-z
"
${
SECRET
}
"
-o
-z
"
${
SECRET
}
"
]
&&
\
[
-z
"
${
PORT
}
"
-o
-z
"
${
SECRET
}
"
-o
-z
"
${
TAG
}
"
]
&&
\
error
"Not enough options: -p '
${
PORT
}
' -s '
${
SECRET
}
' -t '
${
TAG
}
'"
# validate format
...
...
@@ -62,7 +76,7 @@ if [ -n "${PORT}" -o -n "${SECRET}" -o -n "${TAG}" ]; then
[
-n
"
`
echo
$TAG
|
grep
-x
'[[:xdigit:]]\{32\}'
`
"
]
||
\
error
"Invalid tag. Should be 32 chars of 0-9 a-f"
exec
$CMD
-mtproto_proxy
ports
"[#{name => mtproto_proxy, port =>
$PORT
, secret => <<
\"
$SECRET
\"
>>, tag => <<
\"
$TAG
\"
>>}]"
exec
$CMD
$DD_ARG
-mtproto_proxy
ports
"[#{name => mtproto_proxy, port =>
$PORT
, secret => <<
\"
$SECRET
\"
>>, tag => <<
\"
$TAG
\"
>>}]"
else
exec
$CMD
exec
$CMD
$DD_ARG
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment