File tree Expand file tree Collapse file tree
liberator/src/main/kotlin/de/binarynoise/liberator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,9 +171,9 @@ class Liberator(
171171 return recurse(response, depth + 1 )
172172 }
173173
174- log(" solver ${solver::class .simpleName} found for $response .requestUrl" )
174+ log(" solver ${solver::class .simpleName} found for ${ response.requestUrl} " )
175175 solver.solve(client, response, cookies)
176- log(" solver ${solver::class .simpleName} finished processing $response .requestUrl" )
176+ log(" solver ${solver::class .simpleName} finished processing ${ response.requestUrl} " )
177177
178178 return LiberationResult .Success (response.requestUrl.toString())
179179 } catch (e: Exception ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import de.binarynoise.util.okhttp.readText
1313import de.binarynoise.util.okhttp.requestUrl
1414import okhttp3.Cookie
1515import okhttp3.HttpUrl.Companion.toHttpUrl
16+ import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
1617import okhttp3.OkHttpClient
1718import okhttp3.Response
1819
@@ -73,13 +74,13 @@ object CloudWifiRedirect : PortalLiberator {
7374 .getElementsByTag(" script" )
7475 .map { it.attr(" src" ) }
7576 .filter { it.isNotEmpty() }
76- .map { it.toHttpUrl () }
77+ .mapNotNull { it.toHttpUrlOrNull () }
7778 .any { url -> url.host == " start.cloudwifi.de" && url.pathSegments.any { it == " redirect" } }
7879 }
7980
8081 override fun solve (client : OkHttpClient , response : Response , cookies : Set <Cookie >) {
8182 val html1 = response.parseHtml()
82- val script1 = html1.getElementsByTag(" body" ).single().getElementsByTag(" script" ).single().wholeText ()
83+ val script1 = html1.getElementsByTag(" body" ).single().getElementsByTag(" script" ).single().data ()
8384 val assignments = RhinoParser ().parseAssignments(script1)
8485
8586 val deviceMac = assignments[" FX_redirect.0" ] ? : error(" no deviceMac" )
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ object Conn4 : PortalLiberator {
202202 }
203203
204204 fun getTariffPreference (session : JSONObject ): List <JSONObject > {
205- val tariffs = session.getJSONArray(" tariffs" ).filterIsInstance<JSONObject >()
205+ val tariffs = session.getJSONArray(" tariffs" ).asIterable(). filterIsInstance<JSONObject >()
206206 if (tariffs.hasOneEntry) return tariffs
207207 fun JSONObject.isBooleanEqualTo (key : String , value : Boolean , default : Boolean ): Boolean {
208208 if (! this .has(key)) return default
@@ -359,7 +359,7 @@ object Conn4 : PortalLiberator {
359359 cookies : Set <Cookie >,
360360 ) {
361361 val token = cookies.find { it.name == " wbs-token" }?.value ? : error(" no wbs-token cookie" )
362- val apiBase = response.requestUrl.resolveOrThrow(" /wbs/api/v1" ) // TODO: properly parse wbs api base from scrips
362+ val apiBase = response.requestUrl.resolveOrThrow(" /wbs/api/v1/ " ) // TODO: properly parse wbs api base from scrips
363363 tryPossibleTariffs(client, apiBase, token, site_id)
364364 }
365365}
Original file line number Diff line number Diff line change @@ -39,10 +39,9 @@ object DBWifi : PortalLiberator {
3939 check(JSONObject (response2.readText()).getString(" result" ) == " success" ) { " response does not contain success" }
4040 }
4141 " sp" == response1.requestUrl.firstPathSegment -> {
42- // works
4342 log(" sp" )
4443 client.postForm(
45- response .requestUrl, " /login" , mapOf (
44+ response1 .requestUrl, " /login" , mapOf (
4645 " login" to " oneclick" ,
4746 " oneSubscriptionForm_connect_policy_accept" to " on" ,
4847 )
Original file line number Diff line number Diff line change @@ -34,11 +34,11 @@ object SocialwiBox : PortalLiberator {
3434 val response3 = client.get(response.requestUrl, location2).followRedirects(client)
3535 val html3 = response3.parseHtml()
3636
37- val script3 = html3.getElementsByTag(" script" ).find { it.wholeText ().contains(" redirectPost" ) }
37+ val script3 = html3.getElementsByTag(" script" ).find { it.data ().contains(" redirectPost" ) }
3838 ? : error(" no script with redirectPost" )
3939
4040 val regex = " redirectPost\\ ('([^']+)',\\ s*(\\ {.*\\ })\\ );" .toRegex()
41- val match = regex.find(script3.wholeText ()) ? : error(" no match for redirectPost regex" )
41+ val match = regex.find(script3.data ()) ? : error(" no match for redirectPost regex" )
4242 val url = match.groups[1 ]?.value ? : error(" no url in match" )
4343 val data = match.groups[2 ]?.value ? : error(" no data in match" )
4444 val json = JSONObject (data)
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package de.binarynoise.liberator.portals
33import de.binarynoise.liberator.PortalLiberator
44import de.binarynoise.liberator.PortalLiberatorConfig
55import de.binarynoise.liberator.SSID
6+ import de.binarynoise.liberator.asIterable
67import de.binarynoise.liberator.cast
78import de.binarynoise.util.okhttp.checkSuccess
89import de.binarynoise.util.okhttp.postJson
@@ -61,7 +62,7 @@ object Unwired : PortalLiberator {
6162 )
6263 val json1 = JSONObject (response1.readText())
6364
64- val pages = json1.getJSONObject(" data" ).getJSONObject(" splashpage" ).getJSONArray(" pages" )
65+ val pages = json1.getJSONObject(" data" ).getJSONObject(" splashpage" ).getJSONArray(" pages" ).asIterable()
6566
6667 val widgets = pages.flatMap { it.cast<JSONObject >().getJSONArray(" widgets" ) }
6768
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package de.binarynoise.liberator.portals
33import de.binarynoise.liberator.Experimental
44import de.binarynoise.liberator.PortalLiberator
55import de.binarynoise.liberator.SSID
6+ import de.binarynoise.liberator.asIterable
67import de.binarynoise.liberator.tryOrNull
78import de.binarynoise.util.okhttp.get
89import de.binarynoise.util.okhttp.parseJsonObject
@@ -28,7 +29,7 @@ object VodafoneHotspot : PortalLiberator {
2829 override fun solve (client : OkHttpClient , response : Response , cookies : Set <Cookie >) {
2930 val session = client.get(response.requestUrl, " /api/v4/session" ).parseJsonObject()
3031 val sessionToken = session.getString(" session" )
31- val landingPageElements = session.getJSONArray(" landingPageElements" )
32+ val landingPageElements = session.getJSONArray(" landingPageElements" ).asIterable()
3233 val landingPageLoginProfileId = landingPageElements.filterIsInstance<JSONObject >()
3334 .first { tryOrNull { it.getString(" type" ) } == " loginProfile" }
3435 .getString(" value" )
You can’t perform that action at this time.
0 commit comments