{"id":16506053,"url":"https://github.com/fireinrain/cf-speedtester","last_synced_at":"2025-10-28T01:30:25.201Z","repository":{"id":189208317,"uuid":"680253488","full_name":"fireinrain/cf-speedtester","owner":"fireinrain","description":"A golang library to use cloudflare speed test function. use it in your own golang project(一个使用cloudflare ip速度测试功能的golang库。可以在自己的golang项目中使用)","archived":false,"fork":false,"pushed_at":"2023-09-17T12:50:41.000Z","size":4938,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-11T15:16:18.432Z","etag":null,"topics":["cdn","cf-better-ip","cloudflare","cloudflare-speedtest","golang","golang-library","speedtest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fireinrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-18T18:13:42.000Z","updated_at":"2024-08-07T18:48:23.000Z","dependencies_parsed_at":"2023-08-18T20:01:23.120Z","dependency_job_id":null,"html_url":"https://github.com/fireinrain/cf-speedtester","commit_stats":null,"previous_names":["fireinrain/cf-speedtester"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireinrain%2Fcf-speedtester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireinrain%2Fcf-speedtester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireinrain%2Fcf-speedtester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireinrain%2Fcf-speedtester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireinrain","download_url":"https://codeload.github.com/fireinrain/cf-speedtester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860298,"owners_count":16556019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","cf-better-ip","cloudflare","cloudflare-speedtest","golang","golang-library","speedtest"],"created_at":"2024-10-11T15:16:50.796Z","updated_at":"2025-10-28T01:30:24.365Z","avatar_url":"https://github.com/fireinrain.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cf-speedtester\nA golang library to use cloudflare speed test function. use it in your own golang project.\n\n# why you write this golang library\nI want to use cloudflare cdn ip speed test in my own project.\nthere is a command-line tool called [CloudflareSpeedTest](https://github.com/XIU2/CloudflareSpeedTest), but if \nyou want to use in your own project,you need wrap it as a bash call.\nso, here is the project.\n\n\n# how to use\n## add this lib to you golang project\n```bash\n# in terminal\ngo get github.com/fireinrain/cf-speedtester@v1.0.6\n# in your project\nimport (\n\t\"github.com/fireinrain/cf-speedtester\"\n)\n\n```\n\n## simple use(use cloudflare official cdn ips)\n```go\n\nclient := cf_speedtester.NewCFSpeedTestClient(\n\t\tconfig.WithMaxDelay(300*time.Millisecond),\n\t\tconfig.WithMinSpeed(2),\n\t\tconfig.WithTestCount(5),\n\t)\nclient.DoSpeedTest()\nresults := client.SpeedResults\nfmt.Println(results)\n\n\n```\n\n\n## export data to cvs\n```go\n\nclient := cf_speedtester.NewCFSpeedTestClient(\n\t\tconfig.WithMaxDelay(300*time.Millisecond),\n\t\tconfig.WithMinSpeed(2),\n\t\tconfig.WithTestCount(5),\n\t)\nclient.DoSpeedTest()\nresults := client.SpeedResults\nfmt.Println(results)\nclient.ExportToCSV(\"results.csv\")\n\n\n```\n\n## use custom download url\n```go\nclient := NewCFSpeedTestClient(\n    config.WithMaxDelay(300*time.Millisecond),\n    config.WithMinSpeed(2),\n    config.WithTestCount(5),\n    config.WithDownloadUrl(\"https://youself-download-url.com\"),\n)\nresult := client.DoSpeedTestForResult()\nfmt.Println(result)\n\n\n```\n\n\n## use with self-find ips that proxied to cloudflare cdn\n```go\n//replace ips that you find proxied for cloudflare cdn\nvar ips = []string{\n\t\t\"193.122.125.193\",\n\t\t\"193.122.119.93\",\n\t\t\"193.122.119.34\",\n\t\t\"193.122.108.223\",\n\t\t\"193.122.114.201\",\n\t\t\"193.122.114.63\",\n\t\t\"193.122.121.37\",\n\t\t\"193.122.113.19\",\n\t\t\"193.122.112.125\",\n\t\t\"193.122.116.161\",\n\t}\nvar ipList []*net.IPAddr\nfor _, ip := range ips {\n    addr := utils.IPStrToIPAddr(ip)\n    ipList = append(ipList, addr)\n}\n\nclient := cf_speedtester.NewCFSpeedTestClient(\n    config.WithMaxDelay(300*time.Millisecond),\n    config.WithMinSpeed(2),\n    config.WithTestCount(1),\n    config.WithIPListForTest(ipList),\n)\nresult := client.DoSpeedTestForResult()\nfmt.Println(result)\n\n\n\n```\n## get the ips banned in mainland china?\nif you find you get the cloudflare ip is banned in china with this library, take it easy and here\nis the solution.\n\n```go\n//develop yourself ip ban check function, and inject to the config\n\nfunc YouselfIPBanChecker(some any) any{\n\t//do you check logic\n\t//notice: you need convert any to handler.PingDelaySet\n\t//and with PingDelaySet,do your check logic and return\n    //checked PingDelaySet\n\treturn some\n}\n//here is an example of a IPBanChecker\nfunc DoIPBanCheck(someData any) any {\n    var result []handler.CloudflareIPData\n    //转型\n    if pingDelaySetValue, ok := someData.(handler.PingDelaySet); ok {\n        log.Println(\"Convert someData to PingDelaySet type success,size is :\", len(pingDelaySetValue))\n        //do ip banned check\n\t\t//DoIPBanCheckInPool if self write check logic, replaced with your check logic\n        checkerResults := DoIPBanCheckInPool(pingDelaySetValue, 3)\n        for _, checkerResult := range checkerResults {\n            if checkerResult.IsBanned == false {\n                result = append(result, *checkerResult.CheckIPAddr)\n            }\n        }\n        log.Println(\"Do ip banned check finished, result size is :\", len(result))\n        return result\n    } else {\n        log.Println(\"Convert someData to PingDelaySet type failed :\", someData)\n    }\n    return someData\n}\nvar ips = []string{\n    \"193.122.125.193\",\n    \"193.122.119.93\",\n    \"193.122.119.34\",\n    \"193.122.108.223\",\n    \"193.122.114.201\",\n    \"193.122.114.63\",\n    \"193.122.121.37\",\n    \"193.122.113.19\",\n}\nvar ipList []*net.IPAddr\nfor _, ip := range ips {\n    addr := utils.IPStrToIPAddr(ip)\n    ipList = append(ipList, addr)\n}\n\nclient := cf_speedtester.NewCFSpeedTestClient(\n    config.WithMaxDelay(300*time.Millisecond),\n    config.WithMinSpeed(2),\n    config.WithTestCount(1),\n    config.WithIPListForTest(ipList),\n    config.WithEnableIPBanCheck(true),\n    config.WithIPBanChecker(YouselfIPBanChecker),\n)\nresult := client.DoSpeedTestForResult()\nfmt.Println(result)\n\n```\n\n## if i want to get specific country ip, what should i do?\n```go\n// you can do like this\n// the lib use geoip2 golang, use Country.mmdb.\n// it may not exactly, but seems work well. \n\nvar ips = []string{\n    \"193.122.125.193\",\n    \"193.122.119.93\",\n    \"193.122.119.34\",\n    \"193.122.108.223\",\n    \"193.122.114.201\",\n    \"193.122.114.63\",\n    \"193.122.121.37\",\n    \"193.122.113.19\",\n    \"146.70.175.116\",\n}\nvar ipList []*net.IPAddr\nfor _, ip := range ips {\n    addr := handler.IPStrToIPAddr(ip)\n    ipList = append(ipList, addr)\n}\n\nclient := NewCFSpeedTestClient(\n    config.WithMaxDelay(300*time.Millisecond),\n    config.WithMinSpeed(2),\n    config.WithTestCount(1),\n    config.WithIPListForTest(ipList),\n    // i want to get the cdn ip belongs to NL(Netherlands ISO code)\n\t// the priority is lowered sequentially\n    config.WithWantedISOIP([]string{\"NL\",\"US\"}),\n    config.WithEnableIPBanCheck(true),\n    config.WithIPBanChecker(YouselfIPBanChecker),\n)\nresult := client.DoSpeedTestForResult()\nfmt.Println(result)\n\n\n```\n# issues?\n- download speed always 0?\nyou should change the custom download url, and have a test.\n\n# download urls\nhere are some download speed test urls provided by [PencilNavigator](https://github.com/PencilNavigator), thanks for your efforts.\n- https://testfiles.blockly.cf/100mb.zip\n- https://testfiles.blockly.cf/200mb.zip\n- https://testfiles.blockly.cf/300mb.zip\n- https://testfiles.blockly.cf/400mb.zip\n- https://testfiles.blockly.cf/500mb.zip\n\n\n- https://testfiles.blockly.tk/100mb.zip\n- https://testfiles.blockly.tk/200mb.zip\n- https://testfiles.blockly.tk/300mb.zip\n- https://testfiles.blockly.tk/400mb.zip\n- https://testfiles.blockly.tk/500mb.zip\n\n\n- https://testfiles.blockly.gq/100mb.zip\n- https://testfiles.blockly.gq/200mb.zip\n- https://testfiles.blockly.gq/300mb.zip\n- https://testfiles.blockly.gq/400mb.zip\n- https://testfiles.blockly.gq/500mb.zip\n\n\n- https://testfiles.gssmc.cf/100mb.zip\n- https://testfiles.gssmc.cf/200mb.zip\n- https://testfiles.gssmc.cf/300mb.zip\n- https://testfiles.gssmc.cf/400mb.zip\n- https://testfiles.gssmc.cf/500mb.zip\n\n\n- https://testfiles.gssmc.tk/100mb.zip\n- https://testfiles.gssmc.tk/200mb.zip\n- https://testfiles.gssmc.tk/300mb.zip\n- https://testfiles.gssmc.tk/400mb.zip\n- https://testfiles.gssmc.tk/500mb.zip\n\n\n- https://testfiles.gssmc.gq/100mb.zip\n- https://testfiles.gssmc.gq/200mb.zip\n- https://testfiles.gssmc.gq/300mb.zip\n- https://testfiles.gssmc.gq/400mb.zip\n- https://testfiles.gssmc.gq/500mb.zip\n\n\n- https://testfiles.itkyou.cf/100mb.zip\n- https://testfiles.itkyou.cf/200mb.zip\n- https://testfiles.itkyou.cf/300mb.zip\n- https://testfiles.itkyou.cf/400mb.zip\n- https://testfiles.itkyou.cf/500mb.zip\n\n\n- https://testfiles.itkyou.tk/100mb.zip\n- https://testfiles.itkyou.tk/200mb.zip\n- https://testfiles.itkyou.tk/300mb.zip\n- https://testfiles.itkyou.tk/400mb.zip\n- https://testfiles.itkyou.tk/500mb.zip\n\n\n- https://testfiles.itkyou.gq/100mb.zip\n- https://testfiles.itkyou.gq/200mb.zip\n- https://testfiles.itkyou.gq/300mb.zip\n- https://testfiles.itkyou.gq/400mb.zip\n- https://testfiles.itkyou.gq/500mb.zip\n\n\n- https://testfiles.ityou.cf/100mb.zip\n- https://testfiles.ityou.cf/200mb.zip\n- https://testfiles.ityou.cf/300mb.zip\n- https://testfiles.ityou.cf/400mb.zip\n- https://testfiles.ityou.cf/500mb.zip\n\n\n- https://testfiles.ityou.tk/100mb.zip\n- https://testfiles.ityou.tk/200mb.zip\n- https://testfiles.ityou.tk/300mb.zip\n- https://testfiles.ityou.tk/400mb.zip\n- https://testfiles.ityou.tk/500mb.zip\n\n\n- https://testfiles.ityou.gq/100mb.zip\n- https://testfiles.ityou.gq/200mb.zip\n- https://testfiles.ityou.gq/300mb.zip\n- https://testfiles.ityou.gq/400mb.zip\n- https://testfiles.ityou.gq/500mb.zip\n\n\n- https://testfiles.kiring.cf/100mb.zip\n- https://testfiles.kiring.cf/200mb.zip\n- https://testfiles.kiring.cf/300mb.zip\n- https://testfiles.kiring.cf/400mb.zip\n- https://testfiles.kiring.cf/500mb.zip\n\n\n- https://testfiles.kiring.tk/100mb.zip\n- https://testfiles.kiring.tk/200mb.zip\n- https://testfiles.kiring.tk/300mb.zip\n- https://testfiles.kiring.tk/400mb.zip\n- https://testfiles.kiring.tk/500mb.zip\n\n\n- https://testfiles.kiring.gq/100mb.zip\n- https://testfiles.kiring.gq/200mb.zip\n- https://testfiles.kiring.gq/300mb.zip\n- https://testfiles.kiring.gq/400mb.zip\n- https://testfiles.kiring.gq/500mb.zip\n\n\n- https://testfiles.newbeer.cf/100mb.zip\n- https://testfiles.newbeer.cf/200mb.zip\n- https://testfiles.newbeer.cf/300mb.zip\n- https://testfiles.newbeer.cf/400mb.zip\n- https://testfiles.newbeer.cf/500mb.zip\n\n\n- https://testfiles.newbeer.gq/100mb.zip\n- https://testfiles.newbeer.gq/200mb.zip\n- https://testfiles.newbeer.gq/300mb.zip\n- https://testfiles.newbeer.gq/400mb.zip\n- https://testfiles.newbeer.gq/500mb.zip\n\n# special thanks \n- CloudflareSpeedTest,Thanks very much !\n- Jetbrains Goland IDE, Thanks very much !\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireinrain%2Fcf-speedtester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireinrain%2Fcf-speedtester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireinrain%2Fcf-speedtester/lists"}