Git Product home page Git Product logo

jsmtproxy's Introduction

JSMTProxy

Telegram Channel

High Performance NodeJS MTProto Proxy

Latest Active MTProto Proxies: https://t.me/MTProxy

Linux Installation

Install NodeJS, NPM, GIT and PM2 on your server:

Debian & Ubuntu

$> apt-get install nodejs npm git
$> npm install pm2 -g

CentsOS & RHEL

$> yum install nodejs npm git
$> npm install pm2 -g

Check the version of NodeJS, it should be version 6 or higher:

$> nodejs -v
v6.14.2

If it is lower than 6, you need to upgrade your linux OS or install nodejs from its website: https://nodejs.org/en/download/

Clone repository on your server:

$> git clone https://github.com/FreedomPrevails/JSMTProxy.git

Enter JSMTProxy directory and edit config file (config.json) if you wish. You can change the secret and listening port. it is in json format.

{
  "port":6969,
  "secret":"b0cbcef5a486d9636472ac27f8e11a9d"
}

Start the app in cluster mode using pm2:

$> pm2 start mtproxy.js -i max

You can use pm2 to list running processes and check their logs:

$> pm2 list
$> pm2 log mtproxy
$> pm2 show mtproxy

Windows Installation

Download and install NodeJS for Windows using this link: https://nodejs.org/dist/v8.11.2/node-v8.11.2-x64.msi

After installation is complete, enter "Command Prompt" and install PM2 by following command:

C:\> npm install pm2 -g

Download JSMTProxy using this link: https://github.com/FreedomPrevails/JSMTProxy/archive/master.zip

Extract the zip file into a new folder. Edit config.json (as explained above) if you wish to change port number or secret.

Start the proxy server from "Command Prompt" by following command:

C:\> pm2 start mtproxy.js -i max

Note: You may need to open the proxy port number in your Windows firewall in order for it to accept connections.

License

MIT License

Copyright (c) 2018 JSMTProxy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jsmtproxy's People

Contributors

freedomprevails avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsmtproxy's Issues

IP white list method - amazon changer & checker - local server tunnel

Hello

When we start a Telegram proxy server, the IP server in Iran is blocked after a short time

Can anyone help regarding the method of getting the IP in the white list?

Or in relation to Amazon Checker and Changer

Or how to tunnel a local server to the main proxy server?

thanks

How Reach Besr Ping?

Hello Bro My Server Not So Stable Sometimes My Server Ping Higher Than 200 And its not so good.
My server datacenter is hetzner.
How i Can Reach Best Ping?

Doesn't work

Hi
I installed x86 nodejs on my windows vps

i run this command on command line :
Pm2 start mtproxy.js -i -1
Because when i type
Pm2 start mtproxy.js -i max
A lot of cmd window will open and close consistently and never stops

Above that
Its dont working
I also opened my custom port on firewall

not work on evennode.com

hi
i have an account on evennode.com ( free account )
it use port 3000 ( use nginx on port 80 and send data to port 3000 to app ) ( process.env.PORT== 3000 )
it support websockets ( https://www.evennode.com/docs/websockets )
i run your app and it run with no error but i can not use it on telegram
i see this on logs every second : Connection per seconds :0 dc1:0 dc2:0 dc3:0 dc4:0 dc5:0
it doesn't work on telegram
can you test it on evennode.com ?it is very important for me
thanks

Error: CERT_UNTRUSTED

Hello,
i tried installing as instructed but when running npm install pm2 -g i get the following error

root@server:~/JSMTProxy# npm install pm2 -g
npm http GET https://registry.npmjs.org/pm2
npm http GET https://registry.npmjs.org/pm2
npm http GET https://registry.npmjs.org/pm2
npm ERR! Error: CERT_UNTRUSTED
npm ERR!     at SecurePair.<anonymous> (tls.js:1370:32)
npm ERR!     at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:982:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:469:13)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:366:25)
npm ERR!     at doWrite (_stream_writable.js:223:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:213:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:180:11)
npm ERR!     at write (_stream_readable.js:583:24)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.13.0-149-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "pm2" "-g"
npm ERR! cwd /root/JSMTProxy
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /root/JSMTProxy/npm-debug.log
npm ERR! not ok code 0

crash JSMtproxy after few day

Hi
I install and use JSMtproxy, Unfortunately, this proxy crashes after one or two days and not work through, I reboot by stop and start pm2...

please help me

Auto start after reboot

How to reboot the mtproxy.js file automatically?
or "pm2 start mtproxy.js -i max" command

-- I do not have much information from nodejs

PM2 Spawning daemon

i installed pm2 on windows 7 (vps)

after run this command pm2 stop all

i can't start it again.

[PM2] Spawning PM2 daemon with pm2_home=C:\Users\admin.pm2

Any help to get it working smoothly?

issue with user

hi
i run mtproto on windows vps, and I successfully connected to it
but there is issue, when i set this comment on cmd "pm2 list" Nothing show except cluster(no user found)
when i shutdown system conection in telegram lost
srry for bad english

dont run on ubuntu

i do manual step by step
an then get this error

PM2 | Error: ENOENT: no such file or directory, uv_cwd PM2 | at Object.resolve (path.js:1077:24) PM2 | at Function.Module._resolveLookupPaths (internal/modules/cjs/loader.js:480:17) PM2 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:575:20) PM2 | at Function.Module._load (internal/modules/cjs/loader.js:508:25) PM2 | at Module.require (internal/modules/cjs/loader.js:637:17) PM2 | at require (internal/modules/cjs/helpers.js:22:18) PM2 | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:13:15) PM2 | at Module._compile (internal/modules/cjs/loader.js:701:30) PM2 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) PM2 | at Module.load (internal/modules/cjs/loader.js:600:32) PM2 | 2019-05-18T16:10:54: PM2 log: App name:mtproxy id:1 disconnected PM2 | 2019-05-18T16:10:54: PM2 log: App [mtproxy:1] exited with code [1] via signal [SIGINT] PM2 | 2019-05-18T16:10:54: PM2 log: Script /root/JSMTProxy/mtproxy.js had too many unstable restarts (16). Stopped. "errored" PM2 | 2019-05-18T16:10:54: PM2 error: Cancelling versioning data parsing

-S <secret1> -S <secret2>

hi,
for MTProxy
you can set multiple secrets: -S -S
but windows (node.js)
config file config.json:
{
"port":1984,
"secret":"7ec6776bd296368a0ce3c06b63951b0e"
}

How is that?

TypeError: Cannot read property 'writable' of undefined

node version 8.9.3

i have error in this part of code


 if (!socket.server_socket.writable) {
                            socket.server_socket.destroy();
                        }

if (!socket.server_socket.writable) {
                                                  ^

TypeError: Cannot read property 'writable' of undefined
    at Socket.<anonymous> (\mtproxy.js:243:51)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)
C:\nodemt\node_modules\starter\mtproxy.js:243

begginer guide

hi
is there any guide to making clients and adding restriction using pm2? like adding a specif user secret and giving it a time limit or bandwidth limit?

How Can Fix This Errors?

I Receive To Many Of This Errors In My MTProxy Server:
TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) TypeError: Cannot read property 'writable' of undefined at Socket.<anonymous> (C:\JSMTProxy\mtproxy.js:223:32) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20)
I Attach My Server Status Image:
capture
@FreedomPrevails

HI.I BUY A NEW SERVER

hi dears i buy new server and by ssh run all your code
when i change port my server not loaded and need to reload
may you help me config port?for new server for run this lovely mtproto?
i need 0 to 100
sorry for my bad english

Windows installation enhancement

hello again!

thanks for the windows tutorial. I installed it on my server and it worked. however, there are 2 issues that would make it even better.

1- Add autostart feature.
2- install as a service so it runs even if the user doesn't log in. this way those 2 annoying node command prompts will go away as well.

some people suggest using nssm but I know pm has windows service and startup feature.

.

.

how change size secret code

Hi
Unfortunately, all proxies fail to detect the state using the packet size of the protocol
Please advise how to resize the secret code so that the package cannot be identified

how change this code use66 char secret code?


let buf64 = Buffer.allocUnsafe(64);
			data.copy(buf64);
			let keyIv = Buffer.allocUnsafe(48);
			buf64.copy(keyIv, 0, 8);

			let decryptKey_client = Buffer.allocUnsafe(32);
			keyIv.copy(decryptKey_client, 0, 0);

			let decryptIv_client = Buffer.allocUnsafe(16);
			keyIv.copy(decryptIv_client, 0, 32);

			reverseInplace(keyIv);

			let encryptKey_client = Buffer.allocUnsafe(32);
			keyIv.copy(encryptKey_client, 0, 0);

			let encryptIv_client = Buffer.allocUnsafe(16);
			keyIv.copy(encryptIv_client, 0, 32);

			let binSecret = Buffer.from(configObj.secret, 'hex');

			decryptKey_client = crypto.createHash('sha256').update(Buffer.concat([decryptKey_client, binSecret])).digest();
			encryptKey_client = crypto.createHash('sha256').update(Buffer.concat([encryptKey_client, binSecret])).digest();

			socket.cipher_dec_client = crypto.createCipheriv('aes-256-ctr', decryptKey_client, decryptIv_client);
			socket.cipher_enc_client = crypto.createCipheriv('aes-256-ctr', encryptKey_client, encryptIv_client);

			let dec_auth_packet = socket.cipher_dec_client.update(buf64);
			socket.dcId = Math.abs(dec_auth_packet.readInt16LE(60)) - 1;

			for (var i = 0; i < 4; i++) {
				if (dec_auth_packet[56 + i] != 0xef) {
					socket.destroy();
					return;
				}
			}

			if (socket.dcId > 4 || socket.dcId < 0) {
				socket.destroy();
				return;
			}

			data = data.slice(64, data.length);
			socket.init = true;

Telegram X Android problem

Tnx , This really works well on Windows Server 2008
but my proxy gets error on Telegram X android

Telegram Android and Telegram Desktop are OK
Problem is Telegram X Android (new version supports mtproto)

Whats Solution?

Run with Open VPN

Hello there, I have a server (with Windows 10 installed) which is located in iran so telegram is blocked in the first place, I installed OpenVpn and tunnel the internet to outside of iran and set up JSMProxy as doc said, But i think it not enough because i couldnt connect to my server is there anything can i do ?

can i add multiple secret in same port?

hi
good time
can i add multiple secret in same port?

{
"port":443,
"secret":"00000000000000000000000000000000","11112222333344445555666677778888",
}

3 years ago I managed to do this and work proxy
But now, every time I tried, it did not work
please guide me

High CPU load


1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4
1|mtproxy  | SHORT ON IDLE SERVER CONNECTIONS! dcId: 4

Also have

TypeError: Cannot read property 'substr' of undefined
    at Socket.<anonymous> (/opt/JSMTProxy/mtproxy.js:158:41)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:597:20)

I have these errors in logs and even if I have only 1 connected client - cpu load is near 60%

OS: Ubuntu 18.04
NodeJS: v8.11.2
pm2: 2.10.4

Connections per second: 70 DC1: 7 DC2: 13 DC3: 1 DC4: 48 DC5: 2
Connections per second: 58 DC1: 2 DC2: 8 DC3: 1 DC4: 48 DC5: 0
Connections per second: 57 DC1: 2 DC2: 7 DC3: 1 DC4: 48 DC5: 1
Connections per second: 58 DC1: 2 DC2: 7 DC3: 1 DC4: 48 DC5: 1
Connections per second: 55 DC1: 2 DC2: 6 DC3: 0 DC4: 48 DC5: 1
Connections per second: 59 DC1: 2 DC2: 8 DC3: 1 DC4: 49 DC5: 1
Connections per second: 59 DC1: 2 DC2: 8 DC3: 1 DC4: 49 DC5: 1
Connections per second: 54 DC1: 1 DC2: 7 DC3: 1 DC4: 46 DC5: 0
Connections per second: 55 DC1: 2 DC2: 7 DC3: 1 DC4: 46 DC5: 1
Connections per second: 58 DC1: 2 DC2: 8 DC3: 1 DC4: 47 DC5: 2
Connections per second: 56 DC1: 4 DC2: 7 DC3: 0 DC4: 46 DC5: 1
Connections per second: 57 DC1: 2 DC2: 8 DC3: 1 DC4: 47 DC5: 1

So looks like somehow there is some DDOS on this server. Is there any way to queue connections and etc to protect from very often requests?

UPD:
With
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

I checked which IPs are ddosing port 6969. So for some reason they are telegram DC servers!

   229: 149.154.167.51
   2297: 149.154.167.91

secret padding support

Hi,
In standard version if you start the secret with dd, it does a random padding on the client side!
However, this does not work on this script! I use windows!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.