cfsolve 0.1.4-x86_64-linux-gnu → 0.1.5-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +26 -6
- data/UPSTREAM.md +23 -8
- data/lib/cfsolve/cfsolve-engine +0 -0
- data/lib/cfsolve/profiles/safari-26-ios/answers.json +805 -797
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +909 -899
- data/lib/cfsolve/version.rb +2 -2
- data/lib/cfsolve.rb +22 -11
- metadata +1 -3
- data/lib/cfsolve/profiles/chrome-157-macos/answers.json +0 -4777
- data/lib/cfsolve/profiles/chrome-157-macos.json +0 -613
data/lib/cfsolve/version.rb
CHANGED
data/lib/cfsolve.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Cfsolve
|
|
|
14
14
|
|
|
15
15
|
# Reusable browser configuration. Each call runs with its own connections and cookies.
|
|
16
16
|
class Browser
|
|
17
|
-
DEFAULT_PROFILE = File.expand_path("../cfsolve/profiles/
|
|
17
|
+
DEFAULT_PROFILE = File.expand_path("../cfsolve/profiles/safari-26-ios.json", __FILE__).freeze
|
|
18
18
|
EXECUTABLE = File.expand_path("../cfsolve/cfsolve-engine", __FILE__).freeze
|
|
19
19
|
ERRORS = {
|
|
20
20
|
"configuration" => ConfigurationError,
|
|
@@ -73,23 +73,34 @@ module Cfsolve
|
|
|
73
73
|
|
|
74
74
|
request[:configuration] = JSON.parse(@configuration)
|
|
75
75
|
request[:timeout] = timeout
|
|
76
|
+
Timeout.timeout(timeout, TimeoutError, "The solver exceeded its deadline") do
|
|
77
|
+
attempts = 0
|
|
78
|
+
begin
|
|
79
|
+
attempts += 1
|
|
80
|
+
execute(request)
|
|
81
|
+
rescue UnsupportedError
|
|
82
|
+
retry if attempts < 3
|
|
83
|
+
raise
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def execute(request)
|
|
76
89
|
child_input, input = IO.pipe
|
|
77
90
|
output, child_output = IO.pipe
|
|
78
91
|
pid = Process.spawn(EXECUTABLE, in: child_input, out: child_output, err: File::NULL)
|
|
79
92
|
status = nil
|
|
80
93
|
child_input.close
|
|
81
94
|
child_output.close
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
raise ERRORS.fetch(error.fetch("kind"), Error), error.fetch("message")
|
|
90
|
-
end
|
|
91
|
-
result
|
|
95
|
+
input.write(JSON.generate(request))
|
|
96
|
+
input.close
|
|
97
|
+
result = JSON.parse(output.read)
|
|
98
|
+
_, status = Process.wait2(pid)
|
|
99
|
+
raise Error, "The solver process failed" unless status.success?
|
|
100
|
+
if (error = result["error"])
|
|
101
|
+
raise ERRORS.fetch(error.fetch("kind"), Error), error.fetch("message")
|
|
92
102
|
end
|
|
103
|
+
result
|
|
93
104
|
rescue Errno::ENOENT
|
|
94
105
|
raise ConfigurationError, "The cfsolve executable is missing; reinstall the gem", cause: nil
|
|
95
106
|
rescue JSON::ParserError, IOError, Errno::EPIPE
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cfsolve
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: x86_64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Oliver Morgan
|
|
@@ -574,8 +574,6 @@ files:
|
|
|
574
574
|
- UPSTREAM.md
|
|
575
575
|
- lib/cfsolve.rb
|
|
576
576
|
- lib/cfsolve/cfsolve-engine
|
|
577
|
-
- lib/cfsolve/profiles/chrome-157-macos.json
|
|
578
|
-
- lib/cfsolve/profiles/chrome-157-macos/answers.json
|
|
579
577
|
- lib/cfsolve/profiles/safari-26-ios.json
|
|
580
578
|
- lib/cfsolve/profiles/safari-26-ios/answers.json
|
|
581
579
|
- lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json
|