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
30e8eca8
Unverified
Commit
30e8eca8
authored
Jul 28, 2019
by
Sergey Prokhorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Print proxy links based on a set of enabled protocols on start
parent
41870920
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
7 deletions
+38
-7
mtproto_proxy_app.erl
src/mtproto_proxy_app.erl
+38
-7
No files found.
src/mtproto_proxy_app.erl
View file @
30e8eca8
...
...
@@ -105,14 +105,14 @@ start_proxy(#{name := Name, port := Port, secret := Secret, tag := Tag} = P) ->
num_acceptors
=>
NumAcceptors
,
max_connections
=>
MaxConnections
},
mtp_handler
,
[
Name
,
Secret
,
Tag
]),
Url
=
io_lib
:
format
(
"https://t.me/proxy?server=
~s
&port=
~w
&secret=
~s
"
,
[
application
:
get_env
(
?
APP
,
external_ip
,
ListenIpStr
),
Port
,
Secret
]),
report
(
"Proxy started on
~s
:
~p
with secret:
~s
, tag:
~s~n
Url:
~s~n
"
,
[
ListenIpStr
,
Port
,
Secret
,
Tag
,
Url
]),
Urls
=
build_urls
(
application
:
get_env
(
?
APP
,
external_ip
,
ListenIpStr
),
Port
,
Secret
,
application
:
get_env
(
?
APP
,
allowed_protocols
,
[])),
UrlsStr
=
[
"
\n
"
|
lists
:
join
(
"
\n
"
,
Urls
)],
report
(
"Proxy started on
~s
:
~p
with secret:
~s
, tag:
~s~n
Links:
~s
"
,
[
ListenIpStr
,
Port
,
Secret
,
Tag
,
UrlsStr
]),
Res
.
stop_proxy
(
#
{
name
:
=
Name
})
->
ranch
:
stop_listener
(
Name
).
...
...
@@ -158,11 +158,42 @@ downstream_connections() ->
[
Pid
||
{_,
Pid
,
worker
,
[
mtp_down_conn
]}
<-
supervisor
:
which_children
(
mtp_down_conn_sup
)].
build_urls
(
Host
,
Port
,
Secret
,
Protocols
)
->
MkUrl
=
fun
(
ProtoSecret
)
->
io_lib
:
format
(
"https://t.me/proxy?server=
~s
&port=
~w
&secret=
~s
"
,
[
Host
,
Port
,
ProtoSecret
])
end
,
UrlTypes
=
lists
:
usort
(
lists
:
map
(
fun
(
mtp_abridged
)
->
normal
;
(
mtp_intermediate
)
->
normal
;
(
Other
)
->
Other
end
,
Protocols
)),
lists
:
map
(
fun
(
mtp_fake_tls
)
->
RawSecret
=
mtp_handler
:
unhex
(
Secret
),
ProtoSecret
=
base64url
(
<<
16#ee
,
RawSecret
/
binary
,
"en.wikipedia.org"
>>
),
MkUrl
(
ProtoSecret
);
(
mtp_secure
)
->
ProtoSecret
=
[
"dd"
,
Secret
],
MkUrl
(
ProtoSecret
);
(
normal
)
->
MkUrl
(
Secret
)
end
,
UrlTypes
).
base64url
(
Bin
)
->
%% see https://hex.pm/packages/base64url
<<
<<
(
urlencode_digit
(
D
))
>>
||
<<
D
>>
<=
base64
:
encode
(
Bin
),
D
=/=
$=
>>
.
urlencode_digit
(
$/
)
->
$_
;
urlencode_digit
(
$+
)
->
$-
;
urlencode_digit
(
D
)
->
D
.
-
ifdef
(
TEST
).
report
(
Fmt
,
Args
)
->
?
log
(
debug
,
Fmt
,
Args
).
-
else
.
report
(
Fmt
,
Args
)
->
io
:
format
(
Fmt
,
Args
),
io
:
format
(
Fmt
++
"
\n
"
,
Args
),
?
log
(
info
,
Fmt
,
Args
).
-
endif
.
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