<commit_before>'use strict';

var url = require('url');
var $ = require('jquery');

angular.module('tangHelper.minerService', ['ng'])
    .config(function($httpProvider) {
        $httpProvider.defaults.transformRequest.unshift(
            function(data, headers) {
                if (angular.isObject(data)) {
                    headers()['Content-Type'] =
                        'application/x-www-form-urlencoded; charset=utf-8';
                    return $.param(data);
                }
                return data;
            });
    })
    .factory('operate', function($http, $q, $timeout, formatUserName) {
        return function(minerConfig) {
            function loop() {
                count++;

                $http.post(urlString, {
                    JMIP: minerConfig.IP,
                    JMSK: minerConfig.mask,
                    JGTW: minerConfig.gateway,
                    WPRT: 8000,
                    JSPT: 7478,
                    PDNS: minerConfig.dns1,
                    SDNS: minerConfig.dns2 || '8.8.8.8.8',
                    MURL: minerConfig.pool1URL,
                    MPRT: minerConfig.pool1Port,
                    USEF: username,
                    PASO: 123,
                    GCLK: 270,
                    RNTM: 120,
                    RCTM: 3600,
                    SMRT: 0,
                    update: 'Update/Restart'
                }).then(function(response) {
                    if (response.status === 200) {
                        return df.resolve();
                    }
                    if (count >= 3) {
                        df.reject();
                    } else {
                        loop.timer = $timeout(loop, 500);
                    }
                }, function() {
                    if (count >= 3) {
                        df.reject();
                    } else {
                        loop.timer = $timeout(loop, 500);
                    }
                });
            }

            var urlObject = {
                protocol: 'http',
                host: minerConfig.minerDefaultAddress,
                pathname: 'Settings'
            };
            var urlString = url.format(urlObject);
            var username = formatUserName(minerConfig.username,
                minerConfig.prefix, minerConfig.IP);

            var df = $q.defer();
            var count = 0;

            loop();

            return df.promise;

        };
    });<commit_msg>修复了备用 dns 错误的问题<commit_after>'use strict';

var url = require('url');
var $ = require('jquery');

angular.module('tangHelper.minerService', ['ng'])
    .config(function($httpProvider) {
        $httpProvider.defaults.transformRequest.unshift(
            function(data, headers) {
                if (angular.isObject(data)) {
                    headers()['Content-Type'] =
                        'application/x-www-form-urlencoded; charset=utf-8';
                    return $.param(data);
                }
                return data;
            });
    })
    .factory('operate', function($http, $q, $timeout, formatUserName) {
        return function(minerConfig) {
            function loop() {
                count++;

                $http.post(urlString, {
                    JMIP: minerConfig.IP,
                    JMSK: minerConfig.mask,
                    JGTW: minerConfig.gateway,
                    WPRT: 8000,
                    JSPT: 7478,
                    PDNS: minerConfig.dns1,
                    SDNS: minerConfig.dns2 || '8.8.8.8',
                    MURL: minerConfig.pool1URL,
                    MPRT: minerConfig.pool1Port,
                    USEF: username,
                    PASO: 123,
                    GCLK: 270,
                    RNTM: 120,
                    RCTM: 3600,
                    SMRT: 0,
                    update: 'Update/Restart'
                }).then(function(response) {
                    if (response.status === 200) {
                        return df.resolve();
                    }
                    if (count >= 3) {
                        df.reject();
                    } else {
                        loop.timer = $timeout(loop, 500);
                    }
                }, function() {
                    if (count >= 3) {
                        df.reject();
                    } else {
                        loop.timer = $timeout(loop, 500);
                    }
                });
            }

            var urlObject = {
                protocol: 'http',
                host: minerConfig.minerDefaultAddress,
                pathname: 'Settings'
            };
            var urlString = url.format(urlObject);
            var username = formatUserName(minerConfig.username,
                minerConfig.prefix, minerConfig.IP);

            var df = $q.defer();
            var count = 0;

            loop();

            return df.promise;

        };
    });
{'fraction_non_alphanumeric': 0.10910931174089068, 'fraction_numerical': 0.017611336032388663, 'mean_word_length': 0.9795673076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4369261', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1216, 'n_words': 230}