protected override void Handle(Request req) { JsonObject root = ParseJson(req); List <object> list = (List <object>)root["servers"]; JsonObject obj = (JsonObject)list[0]; ServerListEntry entry = ParseEntry(obj); Info = new ClientStartData(Username, entry.Mppass, entry.IPAddress, entry.Port, entry.Name); }
void DoResume(int mouseX, int mouseY) { if (!resumeValid) { return; } ClientStartData data = new ClientStartData(resumeUser, resumeMppass, resumeIp, resumePort, resumeServer); Client.Start(data, resumeCCSkins, ref game.ShouldExit); }
protected override void Handle(Request req) { int index = 0; bool success = true; JsonObject root = (JsonObject)Json.ParseValue((string)req.Data, ref index, ref success); List <object> list = (List <object>)root["servers"]; JsonObject obj = (JsonObject)list[0]; ServerListEntry entry = ParseEntry(obj); Info = new ClientStartData(Username, entry.Mppass, entry.IPAddress, entry.Port, entry.Name); }
void SaveToOptions(ClientStartData data, bool ccSkins) { if (!Options.Load()) { return; } Options.Set("launcher-dc-username", data.Username); Options.Set("launcher-dc-ip", data.Ip); Options.Set("launcher-dc-port", data.Port); Options.Set("launcher-dc-mppass", Secure.Encode(data.Mppass, data.Username)); Options.Set("launcher-dc-ccskins", ccSkins); Options.Save(); }
ClientStartData GetStartData(string user, string mppass, string ip, string port) { SetStatus(""); if (String.IsNullOrEmpty(user)) { SetStatus("&eUsername required"); return(null); } IPAddress realIp; if (!IPAddress.TryParse(ip, out realIp) && ip != "localhost") { SetStatus("&eInvalid ip"); return(null); } if (ip == "localhost") { ip = "127.0.0.1"; } ushort realPort; if (!UInt16.TryParse(port, out realPort)) { SetStatus("&eInvalid port"); return(null); } if (String.IsNullOrEmpty(mppass)) { mppass = "******"; } ClientStartData data = new ClientStartData(user, mppass, ip, port, ""); if (Utils.CaselessEquals(user, "rand()") || Utils.CaselessEquals(user, "random()")) { rnd.NextBytes(rndBytes); data.Username = Convert.ToBase64String(rndBytes).TrimEnd('='); } return(data); }
void StartClient(int mouseX, int mouseY) { string address = Get(1); int index = address.LastIndexOf(':'); if (index <= 0 || index == address.Length - 1) { SetStatus("&eInvalid address"); return; } string ipPart = address.Substring(0, index); string portPart = address.Substring(index + 1, address.Length - index - 1); ClientStartData data = GetStartData(Get(0), Get(2), ipPart, portPart); if (data == null) { return; } bool ccSkins = ((CheckboxWidget)widgets[view.ccSkinsIndex]).Value; SaveToOptions(data, ccSkins); Client.Start(data, ccSkins, ref game.ShouldExit); }
void ResumeClick( int mouseX, int mouseY ) { if( !resumeValid ) return; ClientStartData data = new ClientStartData( resumeUser, resumeMppass, resumeIp, resumePort ); Client.Start( data, resumeCCSkins, ref game.ShouldExit ); }
ClientStartData GetStartData( string user, string mppass, string ip, string port ) { SetStatus( "" ); if( String.IsNullOrEmpty( user ) ) { SetStatus( "&ePlease enter a username" ); return null; } IPAddress realIp; if( !IPAddress.TryParse( ip, out realIp ) && ip != "localhost" ) { SetStatus( "&eInvalid ip" ); return null; } if( ip == "localhost" ) ip = "127.0.0.1"; ushort realPort; if( !UInt16.TryParse( port, out realPort ) ) { SetStatus( "&eInvalid port" ); return null; } if( String.IsNullOrEmpty( mppass ) ) mppass = "******"; ClientStartData data = new ClientStartData( user, mppass, ip, port ); if( user.ToLowerInvariant() == "rand()" || user.ToLowerInvariant() == "random()") { rnd.NextBytes( rndBytes ); data.Username = Convert.ToBase64String( rndBytes ).TrimEnd( '=' ); } return data; }
void SaveToOptions( ClientStartData data, bool ccSkins ) { if( !Options.Load() ) return; Options.Set( "launcher-dc-username", data.RealUsername ); Options.Set( "launcher-dc-ip", data.Ip ); Options.Set( "launcher-dc-port", data.Port ); Options.Set( "launcher-dc-mppass", Secure.Encode( data.Mppass, data.RealUsername ) ); Options.Set( "launcher-dc-ccskins", ccSkins ); Options.Save(); }