Exemple #1
0
    /// </summary>
    public void StartClient()
    {
        buffer       = new byte[size];
        receiveCache = new List <byte>();

        IPAddress[] adds = Dns.GetHostAddresses(address);

        if (adds[0].AddressFamily == AddressFamily.InterNetworkV6)
        {
            Debug.Log("Connect InterNetworkV6");
            client = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
        }
        else
        {
            Debug.Log("Connect InterNetwork");
            client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        }

        IAsyncResult result = client.BeginConnect(adds, port, AsyncAccept2, client);

        //IAsyncResult result = client.BeginConnect(IPAddress.Parse(address), port, AsyncAccept2, client);

        DelayUtils.Start(waitConnection(result));
        Debug.Log(string.Format("StartClient {0}:{1}", address, port));
    }
Exemple #2
0
    public void StartClient()
    {
        buffer       = new byte[size];
        receiveCache = new List <byte>();

        //判断网络情况  进行链接
        //if (Application.internetReachability == NetworkReachability.NotReachable)
        //{
        //    Debug.Log("没有网络!");
        //    client = null;
        //    return;
        //}
        //else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork ||
        //    Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork) {

        IPAddress[] adds = Dns.GetHostAddresses(address);
        if (adds[0].AddressFamily == AddressFamily.InterNetworkV6)
        {
            Debug.Log("Connect InterNetworkV6");
            client = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
        }
        else
        {
            Debug.Log("Connect InterNetwork");
            client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        }
        //}
        IAsyncResult result = client.BeginConnect(adds, port, AsyncAccept2, client);

        //IAsyncResult result = client.BeginConnect(IPAddress.Parse(address), port, AsyncAccept2, client);

        DelayUtils.Start(waitConnection(result));
        Debug.Log(string.Format("StartClient {0}:{1}", address, port));
    }
Exemple #3
0
        private async Task ScDevice()
        {
            if (this.IsAuthenticated())
            {
                return;
            }

            await ProceedUtils.Proceed <bool?>(this.logger, async() =>
            {
                var session = this.storeService.GetScDevice();
                if (session != null)
                {
                    this.scDevice = session;
                    this.logger.LogTrace(this.scDevice.GetLog());
                    return(true);
                }

                var request = this.makeMoney.ScDevice.ScDevice(new ScDeviceRequest
                {
                    AutoName       = string.Empty,
                    Model          = "Android SDK built for x86",
                    UniqueId       = this.userSettings.UniqueId,
                    Manufacturer   = "Google",
                    AppVesrsion    = "4.0",
                    Carrier        = "Android",
                    Brand          = "google",
                    DeviceLanguage = "en-US",
                    FirebaseToken  = this.userSettings.FirebaseToken,
                    PushId         = string.Empty,
                    ReferalCode    = string.Empty,
                    DeploymentType = "1",
                    ScreenHeight   = "1794",
                    AutoEmail      = string.Empty,
                    OsVersion      = "9",
                    ScreenWidth    = "1080"
                }).SetDefault();

                var response = await request.ExecuteAsync();
                if (response == null)
                {
                    this.logger.LogError("Authorization failed.");
                    DelayUtils.LargeDelay();
                    return(null);
                }

                this.scDevice = response;
                this.logger.LogTrace(this.scDevice.GetLog());
                this.storeService.SaveScDevice(this.scDevice);
                this.isNewDevice = true;
                return(true);
            });
        }
Exemple #4
0
 //异步监听消息
 private void BeginReceive(Socket client)
 {
     try
     {
         //异步方法
         IAsyncResult result = client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, EndReceive2, client);
         DelayUtils.Start(waitReceive(result));
     }
     catch (Exception ex)
     {
         Debug.Log(ex.ToString());
     }
 }
Exemple #5
0
        public async Task Run()
        {
            await this.ScDevice();

            await this.ScSaveFirebaseToken();

            await this.ScNewsAndroid();

            await this.ScCheckInDay();

            while (true)
            {
                var delayed   = false;
                var configure = await this.ads30Service.Configure(this.GetAdColonyConfigureRequest());

                var macros = new[]
                {
                    configure.App.Macros.S2,
                    configure.App.Macros.S3,
                    configure.App.Macros.S4,
                    configure.App.Macros.S5,
                    configure.App.Macros.S6,
                    configure.App.Macros.S7,
                    configure.App.Macros.S8,
                    configure.App.Macros.S9,
                    configure.App.Macros.S10,
                    configure.App.Macros.S11,
                }.Where(m => !string.IsNullOrEmpty(m));

                foreach (var m in macros)
                {
                    var reward = await this.Rewardv4Vc(m);

                    var seAdColonyCredit = await this.SeAdColonyCredit(reward.V4VcCallback);

                    if (string.IsNullOrEmpty(seAdColonyCredit))
                    {
                        continue;
                    }
                    DelayUtils.Delay();
                    delayed = true;
                }

                if (!delayed)
                {
                    DelayUtils.Delay();
                }
            }
        }
Exemple #6
0
        public async Task Surf()
        {
            if (!this.IsAuthenticated())
            {
                return;
            }

            await ProceedUtils.Proceed <bool?>(this.Logger, async() => {
                var getSurfUrlRequest = this.Lr.Ajax.GetSurfUrl(UserSession.UserAccessToken)
                                        .SetAuthCookies(AuthCookies)
                                        .SetSerializer(new JsonSerializer <GetSurfUrlResponseModel>());

                var getSurfUrlResponse = await getSurfUrlRequest.ExecuteAsync();
                this.Logger.LogTrace(getSurfUrlResponse.GetLog());
                DelayUtils.TaskDelay(getSurfUrlResponse.TaskTime);
                if (getSurfUrlResponse.NoAutoSurf())
                {
                    return(true);
                }

                var taskHash = CryptoUtils.GetTaskHash(
                    getSurfUrlResponse.TaskId,
                    UserSession.UserId,
                    string.Empty,
                    this.CommonSecrets.HashKey);

                var recordActionRequest = this.Lr.Ajax.RecordAction(
                    UserSession.UserAccessToken,
                    getSurfUrlResponse.TaskId,
                    string.Empty,
                    taskHash,
                    string.Empty)
                                          .SetAuthCookies(AuthCookies)
                                          .SetSerializer(new JsonSerializer <RecordActionResponseModel>());

                var recordActionResponse = await recordActionRequest.ExecuteAsync();
                this.Logger.LogTrace(recordActionResponse.GetLog());
                return(null);
            });
        }
Exemple #7
0
        public async Task Surf()
        {
            if (!this.IsAuthenticated())
            {
                return;
            }

            var tasksCompleted = new List <TaskCompleted>();
            await ProceedUtils.Proceed <bool?>(this.Logger, async() => {
                var tasks = new List <GetTasksItemModel>();
                foreach (var social in Socials.All)
                {
                    var usersSocial = this.UserSecrets.GetUsersSocial(social.Name);
                    if (usersSocial != null)
                    {
                        foreach (var target in social.Targets)
                        {
                            var ts = await GetTasks(target.Id, usersSocial.Id);
                            this.Logger.LogTrace($"{usersSocial.Name} - {target.Name} : {ts.Length} tasks.");
                            tasks.AddRange(ts);
                        }
                    }
                }
                this.Logger.LogTrace($"Tasks total {tasks.Count}.");
                if (!tasks.Any())
                {
                    this.DoTasksCompleted(tasksCompleted);
                    this.Logger.LogTrace("No tasks for now. Closing...");
                    DelayUtils.LargeDelay();
                    return(true);
                }

                var sorted = tasks
                             .OrderByDescending(t => t.Money)
                             .ThenBy(t => t.TaskTime)
                             .ToArray();
                foreach (var task in sorted)
                {
                    if (task.NoSurf())
                    {
                        continue;
                    }

                    this.Logger.LogTrace(task.GetLog()
                                         .Replace(Currency.Euro, Currency.EuroStr));
                    DelayUtils.TaskDelay(task.TaskTime);

                    var taskHash = CryptoUtils.GetTaskHash(
                        task.TaskId.ToString(),
                        UserSession.UserId,
                        task.SocialId,
                        this.CommonSecrets.HashKey);

                    var recordActionRequest = this.Lr.Ajax.RecordAction(
                        UserSession.UserAccessToken,
                        task.TaskId.ToString(),
                        task.SocialId,
                        taskHash,
                        string.Empty)
                                              .SetAuthCookies(AuthCookies)
                                              .SetSerializer(new JsonSerializer <RecordActionResponseModel>());

                    var recordActionResponse = await recordActionRequest.ExecuteAsync();
                    tasksCompleted.Add(new TaskCompleted(task, recordActionResponse));
                    this.Logger.LogTrace(recordActionResponse.GetLog());
                }

                return(null);
            });
        }
        public async Task Login()
        {
            if (this.IsAuthenticated())
            {
                return;
            }

            await ProceedUtils.Proceed <bool?>(this.Logger, async() => {
                AuthCookies = new AuthCookies
                {
                    Username = this.UserSecrets.Username,
                    Password = this.UserSecrets.Password,
                    UserLang = UserLang,
                    Ga       = "GA1.2.1583055054.1567053894",
                    Gid      = "GA1.2.49410478.1567140764",
                    Gat      = "1"
                };

                var bvbRequest = this.Lr.UserSignIn.SignInBvb(UserLang, ClientVersion)
                                 .SetAuthCookies(AuthCookies)
                                 .SetSerializer(new SignInBvbSerializer());
                var bvbResponse = await bvbRequest.ExecuteAsync();
                AuthCookies.Bvb = bvbResponse.Bvb;

                var sessionIdRequest = this.Lr.UserSignIn.SignInSessionId(UserLang, ClientVersion, "1")
                                       .SetAuthCookies(AuthCookies)
                                       .AddReferer($"https://likesrock.com/client-v2/user_signin.php?user_lang={UserLang}&client_version={ClientVersion}")
                                       .SetSerializer(new WebFormsToJsonSerializer());

                var sessionId            = (await sessionIdRequest.ExecuteUnparsedAsync()).GetCookie(PhpSessionId);
                AuthCookies.PhpSessionId = sessionId;
                this.Logger.LogTrace(AuthCookies.GetLog());

                var session = this.LoadSession();
                if (session != null)
                {
                    UserSession = session;
                    this.Logger.LogTrace(UserSession.GetLog());
                    return(true);
                }

                var loginRequest = this.Lr.Ajax.Login(this.UserSecrets.Username, this.UserSecrets.Password)
                                   .ClearExecInterceptors()
                                   .AddUserAgent(HttpConst.UserAgent)
                                   .AddCookies(AuthCookies)
                                   .AddConnection("keep-alive")
                                   .AddAccept("*/*")
                                   .AddOrigin("https://likesrock.com")
                                   .AddXRequestedWith("XMLHttpRequest")
                                   .AddReferer($"https://likesrock.com/client-v2/user_signin.php?user_lang={UserLang}&client_version={ClientVersion}&security=1")
                                   .AddAcceptLanguage("en-US,en;q=0.8");

                var loginInfo = await loginRequest.ExecuteAsync();
                if (loginInfo == null)
                {
                    this.Logger.LogError("Authorization failed.");
                    DelayUtils.LargeDelay();
                    return(null);
                }

                this.Logger.LogTrace(loginInfo.GetLog());
                UserSession = new UserSession
                {
                    UserId          = loginInfo.UserId,
                    UserName        = loginInfo.UserName,
                    UserEmail       = loginInfo.UserEmail,
                    UserAccessToken = loginInfo.UserAccessToken
                };

                this.SaveSession(UserSession);

                return(true);
            });
        }