Esempio n. 1
0
        public AccountRequestCreate(FormUrlEncodedBody body, bool isCreate)
        {
            FailReason      = null;
            IsCreateRequest = isCreate;
            GamespyCode     = body.GetParamAscii("gsbrcd"); // Usage unknown, but probably stands for "GameSpy xx CoDe".
                                                            // Appears to be constant with respect to a given save file,
                                                            // but it's at least partly dynamically generated (the first
                                                            // four characters are fixed to the original game code). It's
                                                            // possible that this code is randomly generated when the
                                                            // game detects that it is part of a new game-pak/DS pair (it
                                                            // does not, however, appear to be constant with respect to
                                                            // the same game-pak and DS). This field is left empty if
                                                            // logging into GTS.
            SdkVersion   = body.GetParamAscii("sdkver");    // The version of the Nitro SDK used by the game
            ClientUserID = body.GetParamAscii("userid");    // Usage unknown. A 13-digit string formatted using the
                                                            // format string "%013llu". Appears to be constant with
                                                            // respect to a given save file, but may be constant with
                                                            // respect to all identical ROM files.
            Password = body.GetParamAscii("passwd");        // Usage unknown. A 3-digit string formatted using the format
                                                            // string "%03u". Appears to be constant with respect to a
                                                            // given save file, but may be constant with respect to all
                                                            // identical ROM files.
            AccessPtMAC = body.GetParamAscii("bssid");      // The BSSID of the Wi-Fi AP that the DS is connected to as
                                                            // lower-case hex. (e.g. BSSID 00:0d:0b:f8:53:70 would be
                                                            // encoded as 000d0bf85370)
            string apinfo = body.GetParamAscii("apinfo");   // The index of the access point in the Nintendo Wi-Fi

            // Connection Settings used for this connection.
            GameCode  = body.GetParamAscii("gamecd");     // The game's code, as issued by Nintendo (e.g. APAE)
            MakerCode = body.GetParamAscii("makercd");    // Probably the code for the company that made the game,
                                                          // probably formatted using the format string "%02d
                                                          // (Nintendo uses 01)
            UnitCode  = body.GetParamAscii("unitcd");     // Unknown. Always 0
            DeviceMAC = body.GetParamAscii("macadr");     // The MAC address of the Nintendo DS (e.g. 00:09:bf:c3:93:c8
                                                          // would be encoded as 0009bfc393c8)
            Language = body.GetParamAscii("lang");        // The language code (of the game? of the system?), probably
                                                          // formatted using the format string "%02d" (English is 01)
            Birthday = body.GetParamAscii("birth");       // The birth date of the user of the Nintendo DS, formatted
                                                          // using the format string "%02x%02x" % (month, day)
                                                          // (e.g. 071b for July 27)
            DeviceTime = body.GetParamAscii("devtime");   // The local time of DS, formatted "yyMMddHHmmss"
                                                          // (e.g. 140312003606 for ISO date "2014-03-12T00:36:06")
            DevinceName = body.GetParamUTF16("devname");  // The name of the user of the Nintendo DS
            string gsn = body.GetParamUTF16("ingamesn");  // Same as devname, omitted when logging into GTS
        }
Esempio n. 2
0
        private string OnRequestAcLogin(HttpRequest request, FormUrlEncodedBody body, bool isCreate)
        {
            AccountRequestCreate info = new AccountRequestCreate(body, isCreate);

            EventSink.InvokeAccountCreate(info);
            if (info.IsHandled && info.IsSuccess)
            {
                Kernel.WriteLine(Host, $"{request.NetState} authenticated as account '{info.Account}'.");
                return(new HttpResponse(request, contentType: HttpResponse.ContentTypeTextPlain)
                       .AddHeader("NODE", "wifiappe2")
                       .AddHeader("Server", "Nintendo Wii (http)")
                       .AddHeaderDateGMT()
                       .Append(new FormUrlEncodedBody()
                               .AddParamAscii("challenge", info.Account.GsLoginPassword)
                               .AddParamAscii("locator", "gamespy.com")
                               .AddParamAscii("retry", "0")
                               .AddParamAscii("returncd", "001")
                               .AddParamAscii("token", info.Account.GsLoginToken)
                               .AddParamAscii("datetime", DateTime.UtcNow.ToString("yyyyMMddHHmmss"))
                               .Compile()
                               ).Compile());
            }
            else if (info.IsHandled)   // but failed to login, prompt DS for retry
            {
                Console.WriteLine($"{Host}: {request.ClientName} failed to authenticate.");
                return(new HttpResponse(request, contentType: HttpResponse.ContentTypeTextPlain)
                       .AddHeader("NODE", "wifiappw1")
                       .AddHeader("Server", "Nintendo Wii (https)")
                       .AddHeaderDateGMT()
                       .Append(new FormUrlEncodedBody()
                               .AddParamAscii("retry", "0")
                               .AddParamAscii("returncd", info.FailReason)
                               .AddParamAscii("userid", info.ClientUserID)
                               .AddParamAscii("datetime", DateTime.UtcNow.ToString("yyyyMMddHHmmss"))
                               .Compile()
                               ).Compile());
            }
            else
            {
                return(OnUnhandledRequest(request));
            }
        }