Permalink
Browse files

Use the new server host

  • Loading branch information...
Silv3rPRO committed Jan 6, 2019
1 parent 142f7ee commit 842543dde093fb50078a1d1958aecdf01e3d985c
Showing with 17 additions and 16 deletions.
  1. +6 −6 BrightNetwork/SocksConnection.cs
  2. +3 −5 PROProtocol/GameConnection.cs
  3. +4 −3 PROProtocol/GameServer.cs
  4. +4 −2 PROProtocol/MapConnection.cs
@@ -8,7 +8,7 @@ namespace BrightNetwork
{
public static class SocksConnection
{
public static async Task<Socket> OpenConnection(int version, string serverAddress, int serverPort, string socksAddress, int socksPort, string username = null, string password = null)
public static async Task<Socket> OpenConnection(int version, IPAddress serverAddress, int serverPort, string socksAddress, int socksPort, string username = null, string password = null)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var endPoint = new DnsEndPoint(socksAddress, socksPort);
@@ -20,7 +20,7 @@ public static async Task<Socket> OpenConnection(int version, string serverAddres
return socket;
}

public static async Task OpenConnectionFromSocks(Socket socket, int version, string serverAddress, int serverPort,
public static async Task OpenConnectionFromSocks(Socket socket, int version, IPAddress serverAddress, int serverPort,
string username = null, string password = null)
{
if (socket == null)
@@ -56,7 +56,7 @@ private static async Task ReceiveAsync(Socket socket, byte[] buffer, int offset,
await Task.Factory.FromAsync(begin, socket.EndReceive, null);
}

private static async Task HandleSocks5(Socket socket, string serverAddress, int serverPort, string username, string password)
private static async Task HandleSocks5(Socket socket, IPAddress serverAddress, int serverPort, string username, string password)
{
byte[] buffer = new byte[1024];

@@ -118,7 +118,7 @@ private static async Task HandleSocks5(Socket socket, string serverAddress, int
throw new Exception("Received invalid authentication method from the proxy server");
}

byte[] address = IPAddress.Parse(serverAddress).GetAddressBytes();
byte[] address = serverAddress.GetAddressBytes();
byte[] port = BitConverter.GetBytes((ushort)serverPort);
Array.Reverse(port);

@@ -145,11 +145,11 @@ private static async Task HandleSocks5(Socket socket, string serverAddress, int
}
}

private static async Task HandleSocks4(Socket socket, string serverAddress, int serverPort)
private static async Task HandleSocks4(Socket socket, IPAddress serverAddress, int serverPort)
{
byte[] buffer = new byte[1024];

byte[] address = IPAddress.Parse(serverAddress).GetAddressBytes();
byte[] address = serverAddress.GetAddressBytes();
byte[] port = BitConverter.GetBytes((ushort)serverPort);
Array.Reverse(port);

@@ -8,8 +8,6 @@ namespace PROProtocol
{
public class GameConnection : SimpleTextClient
{
private const int ServerPort = 800;

public GameServer Server;

private bool _useSocks;
@@ -41,17 +39,17 @@ public GameConnection(GameServer server, int socksVersion, string socksHost, int

public async void Connect()
{
string host = Server.GetAddress();
var serverHost = Server.GetAddress();

if (!_useSocks)
{
Connect(IPAddress.Parse(host), ServerPort);
Connect(serverHost.Address, serverHost.Port);
}
else
{
try
{
Socket socket = await SocksConnection.OpenConnection(_socksVersion, host, ServerPort, _socksHost, _socksPort, _socksUser, _socksPass);
Socket socket = await SocksConnection.OpenConnection(_socksVersion, serverHost.Address, serverHost.Port, _socksHost, _socksPort, _socksUser, _socksPass);
Initialize(socket);
}
catch (Exception ex)
@@ -1,4 +1,5 @@
using System;
using System.Net;

namespace PROProtocol
{
@@ -10,14 +11,14 @@ public enum GameServer

public static class GameServerExtensions
{
public static string GetAddress(this GameServer server)
public static IPEndPoint GetAddress(this GameServer server)
{
switch (server)
{
case GameServer.Silver:
return "95.183.48.67";
return new IPEndPoint(IPAddress.Parse("185.70.107.113"), 800);
case GameServer.Gold:
return "46.28.205.63";
return new IPEndPoint(IPAddress.Parse("185.70.107.113"), 801);
}
return null;
}
@@ -37,15 +37,17 @@ public MapConnection(int socksVersion, string socksHost, int socksPort, string s

public async void Connect(string serverAddress, int serverPort)
{
var serverIp = IPAddress.Parse(serverAddress);

if (!_useSocks)
{
Connect(IPAddress.Parse(serverAddress), serverPort);
Connect(serverIp, serverPort);
}
else
{
try
{
Socket socket = await SocksConnection.OpenConnection(_socksVersion, serverAddress, serverPort, _socksHost, _socksPort, _socksUser, _socksPass);
Socket socket = await SocksConnection.OpenConnection(_socksVersion, serverIp, serverPort, _socksHost, _socksPort, _socksUser, _socksPass);
Initialize(socket);
}
catch (Exception ex)

0 comments on commit 842543d

Please sign in to comment.