Пример #1
0
        public static ErrorCode Logout(string passport, string ip, out string errorMessage)
        {
            if (passport == null || passport.Length < 10 || !passport.StartsWith("NP"))
            {
                errorMessage = "'passport' is null or corrupted.";
                return(ErrorCode.InvalidArgument);
            }
            if (ip == null)
            {
                try
                {
                    ip = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromPassport(passport);
            }
            catch (Authenticator.InvalidPassportException)
            {
                errorMessage = "'passport' is unrecognizable.";
                return(ErrorCode.InvalidArgument);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, string.Empty, passport);
                return(ErrorCode.Unknown);
            }
            ErrorCode result;

            try
            {
                LogoutResult logoutResult = @default.Logout(passport, ip);
                errorMessage = logoutResult.strErrorMessage;
                result       = (ErrorCode)logoutResult.nErrorCode;
            }
            catch (Exception ex2)
            {
                errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, string.Empty, passport);
                result = ErrorCode.SoapCallFailed;
            }
            return(result);
        }
Пример #2
0
        public static UpgradeGameTokenResult UpgradeGameToken(SecureLoginType type, uint gamecode, string passport, string ip)
        {
            UpgradeGameTokenResult upgradeGameTokenResult = new UpgradeGameTokenResult();
            Default @default = Authenticator.CreateClientFromPassport(passport);
            int     num      = 0;

            if (@default == null)
            {
                upgradeGameTokenResult.nErrorCode      = 20024;
                upgradeGameTokenResult.strErrorMessage = "invalide passport." + Environment.NewLine + "passport : " + passport;
                return(upgradeGameTokenResult);
            }
            for (;;)
            {
                try
                {
                    UpgradeGameTokenResult upgradeGameTokenResult2 = @default.UpgradeGameToken((byte)type, string.Empty, gamecode, passport, string.Empty, ip);
                    upgradeGameTokenResult.nErrorCode      = upgradeGameTokenResult2.nErrorCode;
                    upgradeGameTokenResult.strErrorMessage = upgradeGameTokenResult2.strErrorMessage;
                    upgradeGameTokenResult.strToken        = upgradeGameTokenResult2.strToken;
                }
                catch (Exception ex)
                {
                    if (num < Config.Authenticator.Soap.RetryCount)
                    {
                        num++;
                        if (num == Config.Authenticator.Soap.RetryCount)
                        {
                            @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                        }
                        continue;
                    }
                    upgradeGameTokenResult.nErrorCode      = 20023;
                    upgradeGameTokenResult.strErrorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex.ToString();
                    ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, upgradeGameTokenResult.strErrorMessage, ex.StackTrace, string.Empty, "type: " + type.ToString() + ", passport: " + passport);
                }
                finally
                {
                    @default.Dispose();
                }
                break;
            }
            return(upgradeGameTokenResult);
        }
Пример #3
0
        public static ErrorCode CheckSession2(string passport, string ip, string hwid, uint gamecode, out uint unreadNoteCount, out uint statusFlag, out long nexonSN64, out string nexonID, out string userIP, out byte sex, out ushort age, out string nationCode, out string metaData, out byte secureCode, out byte channelCode, out string channelUID, out bool newMembership, out byte mainAuthLevel, out byte subAuthLevel, out string errorMessage)
        {
            unreadNoteCount = 0u;
            statusFlag      = 0u;
            nexonSN64       = 0L;
            nexonID         = string.Empty;
            userIP          = string.Empty;
            sex             = 0;
            age             = 0;
            nationCode      = string.Empty;
            metaData        = string.Empty;
            secureCode      = 0;
            channelCode     = 0;
            channelUID      = string.Empty;
            newMembership   = false;
            mainAuthLevel   = 0;
            subAuthLevel    = 0;
            if (passport == null || passport.Length < 10 || !passport.StartsWith("NP"))
            {
                errorMessage = "'passport' is null or corrupted.";
                return(ErrorCode.InvalidArgument);
            }
            if (ip == null)
            {
                try
                {
                    ip = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromPassport(passport);
            }
            catch (Authenticator.InvalidPassportException)
            {
                errorMessage = "'passport' is unrecognizable.";
                return(ErrorCode.InvalidArgument);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, nexonID, passport);
                return(ErrorCode.Unknown);
            }
            int       num = Config.Authenticator.Soap.RetryCount;
            ErrorCode result;

            for (;;)
            {
                try
                {
                    if (Config.Authenticator.Soap.SoapVersion == 4)
                    {
                        CheckSessionAndGetInfo4Result checkSessionAndGetInfo4Result = @default.CheckSessionAndGetInfo4(passport, ip, hwid, gamecode);
                        if (checkSessionAndGetInfo4Result.nErrorCode == 0)
                        {
                            unreadNoteCount = checkSessionAndGetInfo4Result.uUnreadNoteCount;
                            statusFlag      = checkSessionAndGetInfo4Result.uStatusFlag;
                        }
                        nexonSN64     = checkSessionAndGetInfo4Result.nNexonSN64;
                        nexonID       = checkSessionAndGetInfo4Result.strNexonID;
                        userIP        = Utility.IPToString(checkSessionAndGetInfo4Result.uIP);
                        sex           = checkSessionAndGetInfo4Result.uSex;
                        age           = checkSessionAndGetInfo4Result.uAge;
                        nationCode    = checkSessionAndGetInfo4Result.strNationCode;
                        metaData      = checkSessionAndGetInfo4Result.strMetaData;
                        secureCode    = checkSessionAndGetInfo4Result.uSecureCode;
                        channelCode   = checkSessionAndGetInfo4Result.uChannelCode;
                        channelUID    = checkSessionAndGetInfo4Result.strChannelUID;
                        newMembership = checkSessionAndGetInfo4Result.bNewMembership;
                        mainAuthLevel = checkSessionAndGetInfo4Result.nMainAuthLevel;
                        subAuthLevel  = checkSessionAndGetInfo4Result.nSubAuthLevel;
                        errorMessage  = checkSessionAndGetInfo4Result.strErrorMessage;
                        result        = (ErrorCode)checkSessionAndGetInfo4Result.nErrorCode;
                        break;
                    }
                    CheckSessionAndGetInfo2Result checkSessionAndGetInfo2Result = @default.CheckSessionAndGetInfo2(passport, ip, hwid, gamecode);
                    if (checkSessionAndGetInfo2Result.nErrorCode == 0)
                    {
                        unreadNoteCount = checkSessionAndGetInfo2Result.uUnreadNoteCount;
                        statusFlag      = checkSessionAndGetInfo2Result.uStatusFlag;
                    }
                    nexonSN64     = (long)checkSessionAndGetInfo2Result.nNexonSN;
                    nexonID       = checkSessionAndGetInfo2Result.strNexonID;
                    userIP        = Utility.IPToString(checkSessionAndGetInfo2Result.uIP);
                    sex           = checkSessionAndGetInfo2Result.uSex;
                    age           = checkSessionAndGetInfo2Result.uAge;
                    nationCode    = checkSessionAndGetInfo2Result.strNationCode;
                    metaData      = checkSessionAndGetInfo2Result.strMetaData;
                    secureCode    = checkSessionAndGetInfo2Result.uSecureCode;
                    newMembership = false;
                    mainAuthLevel = 0;
                    subAuthLevel  = 0;
                    errorMessage  = checkSessionAndGetInfo2Result.strErrorMessage;
                    result        = (ErrorCode)checkSessionAndGetInfo2Result.nErrorCode;
                    break;
                }
                catch (Exception ex2)
                {
                    if (num == 0 || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, nexonID, passport);
                        result = ErrorCode.SoapCallFailed;
                        break;
                    }
                }
                num--;
                if (num == 0)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            return(result);
        }