mirror of https://github.com/FongMi/TV.git
parent
079fe386fa
commit
a6cc97f85f
@ -1,32 +1,14 @@ |
|||||||
package com.hiker.drpy; |
package com.hiker.drpy; |
||||||
|
|
||||||
import com.github.catvod.net.OkHttp; |
|
||||||
|
|
||||||
public class Proxy { |
public class Proxy { |
||||||
|
|
||||||
private static int port; |
private static int port; |
||||||
|
|
||||||
static void tryPort() { |
public static void set(int port) { |
||||||
if (port > 0) return; |
Proxy.port = port; |
||||||
int port = 9978; |
|
||||||
while (port < 9999) { |
|
||||||
boolean ok = string(port).equals("ok"); |
|
||||||
if (ok) Proxy.port = port; |
|
||||||
if (ok) break; |
|
||||||
port++; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private static String string(int port) { |
|
||||||
try { |
|
||||||
return OkHttp.newCall("http://127.0.0.1:" + port + "/proxy?do=port").execute().body().string(); |
|
||||||
} catch (Exception e) { |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
} |
||||||
|
|
||||||
public static String getUrl() { |
public static String getUrl() { |
||||||
tryPort(); |
|
||||||
return "http://127.0.0.1:" + port + "/proxy"; |
return "http://127.0.0.1:" + port + "/proxy"; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue