Skip to content

Commit

Permalink
Merge pull request TelegramMessenger#6 from TelegramMessenger/master
Browse files Browse the repository at this point in the history
add
  • Loading branch information
saturn99 authored Mar 4, 2019
2 parents 2b0cfff + 2c94211 commit 16ddda6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Add `dd` prefix to secret (`cafe...babe` => `ddcafe...babe`) to enable
this mode on client side.

## Systemd example configuration
1. Create systemd service file (it's standart path for the most Linux distros, but you should check it before):
1. Create systemd service file (it's standard path for the most Linux distros, but you should check it before):
```bash
nano /etc/systemd/system/MTProxy.service
```
Expand Down
3 changes: 1 addition & 2 deletions engine/engine-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ int get_port_mod (void) /* {{{ */ {

int try_open_port (int port, int quit_on_fail) /* {{{ */ {
engine_t *E = engine_state;
int enable_ipv6 = engine_check_ipv6_enabled () ? SM_IPV6 : 0;
if (engine_check_tcp_enabled ()) {
struct in_addr l;
l.s_addr = htonl(0x7f000001);
E->sfd = server_socket (port, l, engine_get_backlog (), enable_ipv6);
E->sfd = server_socket (port, l, engine_get_backlog (), 0);
vkprintf (1, "opened tcp socket\n");
if (E->sfd < 0) {
if (quit_on_fail) {
Expand Down
10 changes: 9 additions & 1 deletion mtproto/mtproto-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "mtproto-config.h"
#include "common/tl-parse.h"
#include "engine/engine.h"
#include "engine/engine-net.h"

#ifndef COMMIT
#define COMMIT "unknown"
Expand Down Expand Up @@ -2123,6 +2124,7 @@ void usage (void) {
exit (2);
}

server_functions_t mtproto_front_functions;
int f_parse_option (int val) {
char *colon, *ptr;
switch (val) {
Expand Down Expand Up @@ -2174,6 +2176,10 @@ int f_parse_option (int val) {
ping_interval = PING_INTERVAL;
}
break;
case 2000:
engine_set_http_fallback (&ct_http_server, &http_methods_stats);
mtproto_front_functions.flags &= ~ENGINE_NO_PORT;
break;
case 'S':
case 'P':
{
Expand Down Expand Up @@ -2216,6 +2222,7 @@ int f_parse_option (int val) {
}

void mtfront_prepare_parse_options (void) {
parse_option ("http-stats", no_argument, 0, 2000, "allow http server to answer on stats queries");
parse_option ("mtproto-secret", required_argument, 0, 'S', "16-byte secret in hex mode");
parse_option ("proxy-tag", required_argument, 0, 'P', "16-byte proxy tag in hex mode to be passed along with all forwarded queries");
parse_option ("max-special-connections", required_argument, 0, 'C', "sets maximal number of accepted client connections per worker");
Expand Down Expand Up @@ -2328,7 +2335,8 @@ server_functions_t mtproto_front_functions = {
.FullVersionStr = FullVersionStr,
.ShortVersionStr = "mtproxy",
.parse_function = mtfront_parse_function,
.http_functions = &http_methods_stats
.flags = ENGINE_NO_PORT
//.http_functions = &http_methods_stats
};

int main (int argc, char *argv[]) {
Expand Down

0 comments on commit 16ddda6

Please sign in to comment.