cfsolve 0.1.3-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 +40 -0
- data/README.md +30 -5
- data/UPSTREAM.md +24 -3
- 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 +21 -10
- metadata +1 -1
data/lib/cfsolve/version.rb
CHANGED
data/lib/cfsolve.rb
CHANGED
|
@@ -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
|