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
1cf3a34b
Unverified
Commit
1cf3a34b
authored
Feb 18, 2019
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to configure docker via environment variables
parent
80e6b268
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
15 deletions
+36
-15
README.md
README.md
+9
-3
start.sh
start.sh
+27
-12
No files found.
README.md
View file @
1cf3a34b
...
...
@@ -34,11 +34,17 @@ docker run -d --network=host seriyps/mtproto-proxy
docker run
-d
--network
=
host seriyps/mtproto-proxy
-p
443
-s
d0d6e111bada5511fcce9584deadbeef
-t
dcbe8f1493fa4cd9ab300891c0b5b326
```
or via environmet variables
```
bash
docker run
-d
--network
=
host
-e
MTP_PORT
=
443
-e
MTP_SECRET
=
d0d6e111bada5511fcce9584deadbeef
-e
MTP_TAG
=
dcbe8f1493fa4cd9ab300891c0b5b326 seriyps/mtproto-proxy
```
Where
*
`-p 443`
proxy port
*
`-s d0d6e111bada5511fcce9584deadbeef`
proxy secret (don't append
`dd`
! it should be 32 chars long!)
*
`-t dcbe8f1493fa4cd9ab300891c0b5b326`
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
)
### To run with custom config-file
...
...
start.sh
View file @
1cf3a34b
...
...
@@ -10,6 +10,13 @@ usage() {
echo
"
${
THIS
}
"
echo
"To start in single-port mode configured from command-line:"
echo
"
${
THIS
}
-p <port> -s <secret> -t <ad tag>"
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"
}
error
()
{
...
...
@@ -18,36 +25,44 @@ error() {
exit
1
}
NUM_OPTS
=
0
PORT
=
""
SECRET
=
""
TAG
=
""
# check environment variables
PORT
=
${
MTP_PORT
:-
""
}
SECRET
=
${
MTP_SECRET
:-
""
}
TAG
=
${
MTP_TAG
:-
""
}
# check command line options
while
getopts
"p:s:t:h"
o
;
do
case
"
${
o
}
"
in
p
)
PORT
=
${
OPTARG
}
test
${
PORT
}
-gt
0
-a
${
PORT
}
-lt
65535
||
error
"Invalid port value:
${
PORT
}
"
;;
s
)
SECRET
=
${
OPTARG
}
[
-n
"
`
echo
$SECRET
|
grep
-x
'[[:xdigit:]]\{32\}'
`
"
]
||
error
"Invalid secret. Should be 32 chars of 0-9 a-f"
;;
t
)
TAG
=
${
OPTARG
}
[
-n
"
`
echo
$TAG
|
grep
-x
'[[:xdigit:]]\{32\}'
`
"
]
||
error
"Invalid tag. Should be 32 chars of 0-9 a-f"
;;
h
)
usage
exit
0
esac
NUM_OPTS
=
$((
NUM_OPTS
+
1
))
done
if
[
$NUM_OPTS
-eq
0
]
;
then
exec
$CMD
elif
[
$NUM_OPTS
-eq
3
]
;
then
# 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
}
"
]
&&
\
error
"Not enough options: -p '
${
PORT
}
' -s '
${
SECRET
}
' -t '
${
TAG
}
'"
# validate format
[
${
PORT
}
-gt
0
-a
${
PORT
}
-lt
65535
]
||
\
error
"Invalid port value:
${
PORT
}
"
[
-n
"
`
echo
$SECRET
|
grep
-x
'[[:xdigit:]]\{32\}'
`
"
]
||
\
error
"Invalid secret. Should be 32 chars of 0-9 a-f"
[
-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
\"
>>}]"
else
e
rror
"Not enough options: -p '
${
PORT
}
' -s '
${
SECRET
}
' -t '
${
TAG
}
'"
e
xec
$CMD
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