mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-27 17:55:45 -05:00
Added README and more error Handling to client_socks_proxy example (#846)
* Added README and more error Handling to client_socks_proxy example. * Lint fixing
This commit is contained in:
parent
f509095bd2
commit
ebbd93f2b6
3 changed files with 70 additions and 2 deletions
43
examples/client_socks_proxy/README.md
Normal file
43
examples/client_socks_proxy/README.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
### Socks5 Proxy example
|
||||
|
||||
- **!This Example only works with socks5 proxys!**
|
||||
|
||||
Make sure your proxy connection is working.
|
||||
|
||||
#### Testing proxy connections with curl on Unix systems or Command prompt on Windows:
|
||||
```bash
|
||||
curl -x "socks5://<proxyAddress>:<proxyPort>" "http://ifconfig.me"
|
||||
```
|
||||
If you see an ip address the proxy is working. If you see anything else it's not.
|
||||
|
||||
|
||||
#### These Errors what do they mean????
|
||||
```
|
||||
FetchError: request to https://authserver.mojang.com/authenticate failed, reason: Socket closed
|
||||
```
|
||||
- The Proxy is not working
|
||||
|
||||
|
||||
--------
|
||||
```
|
||||
SocksClientError: Socket closed
|
||||
```
|
||||
- General Socket error Bad Proxy/Proxy refuses the connection
|
||||
|
||||
--------
|
||||
```
|
||||
SocksClientError: connect ECONNREFUSED <some ip address>
|
||||
```
|
||||
- The Connection to the proxy Failed
|
||||
|
||||
--------
|
||||
```
|
||||
SocksClientError: Proxy connection timed out
|
||||
```
|
||||
- Destination Address is wrong/not reachable. Or the Proxy is not working.
|
||||
|
||||
--------
|
||||
```
|
||||
Connection Refused: Blocked by CloudFront/CloudFlare
|
||||
```
|
||||
- Proxy Ip has been banned/block by Cloudflare.
|
|
@ -10,6 +10,25 @@ if (process.argv.length < 6 || process.argv.length > 8) {
|
|||
const proxyHost = process.argv[4]
|
||||
const proxyPort = process.argv[5]
|
||||
|
||||
// This part tests the proxy
|
||||
// You can comment out this part if you know what you are doing
|
||||
require('http').get({
|
||||
method: 'GET',
|
||||
host: 'ifconfig.me',
|
||||
path: '/',
|
||||
agent: new ProxyAgent({ protocol: 'socks5:', host: proxyHost, port: proxyPort })
|
||||
}, (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
process.stdout.write('Proxy ok ip: ')
|
||||
res.pipe(process.stdout)
|
||||
res.on('close', () => {
|
||||
process.stdout.write('\nProxy Connection closed\n')
|
||||
})
|
||||
} else {
|
||||
throw Error('Proxy not working')
|
||||
}
|
||||
})
|
||||
|
||||
const client = mc.createClient({
|
||||
connect: client => {
|
||||
socks.createConnection({
|
||||
|
@ -47,6 +66,12 @@ client.on('disconnect', function (packet) {
|
|||
client.on('end', function () {
|
||||
console.log('Connection lost')
|
||||
})
|
||||
client.on('error', function (error) {
|
||||
console.log('Client Error', error)
|
||||
})
|
||||
client.on('kick_disconnect', (reason) => {
|
||||
console.log('Kicked for reason', reason)
|
||||
})
|
||||
client.on('chat', function (packet) {
|
||||
const jsonMsg = JSON.parse(packet.message)
|
||||
if (jsonMsg.translate === 'chat.type.announcement' || jsonMsg.translate === 'chat.type.text') {
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
"@types/node": "^14.0.1",
|
||||
"espower-loader": "^1.0.0",
|
||||
"intelli-espower-loader": "^1.0.0",
|
||||
"minecraft-packets": "^1.1.5",
|
||||
"minecraft-wrap": "^1.2.3",
|
||||
"mocha": "^8.0.1",
|
||||
"power-assert": "^1.0.0",
|
||||
"require-self": "^0.2.3",
|
||||
"standard": "^16.0.1",
|
||||
"minecraft-packets": "^1.1.5"
|
||||
"standard": "^16.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure/msal-node": "^1.0.0-beta.3",
|
||||
|
|
Loading…
Reference in a new issue