Skip to content

Instantly share code, notes, and snippets.

@bassosimone
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bassosimone/b3e30821472e9307b38b to your computer and use it in GitHub Desktop.
Save bassosimone/b3e30821472e9307b38b to your computer and use it in GitHub Desktop.
Possible abstract API for running libight tests in Java
package io.github.libight.api;
class GenericTest {
public native GenericTest(Map<String, String> settings);
public native void begin();
public native void end();
public void on_test_done() {
/* TODO: override */
}
public void on_report_sent() {
/* TODO: override */
}
}
class LibIght {
public static native void break_loop();
public static native void loop();
};
// FIXME: What is missing is a way to know the progress status
// Maybe we can add a callback called progress?
/// Usage:
import io.github.libight.api.GenericTest;
import io.github.libight.api.LibIght;
class Foo extends GenericTest {
GenericTest(Map<String, String> settings) {
super(settings);
}
public void on_test_done() {
end();
}
public void on_report_sent() {
LibIght.break_loop();
}
};
Map<String, String> settings = new HashMap<>();
settings.put("nameserver", "8.8.8.8");
settings.put("input_filepath", "/foo/bar");
settings.put("test_name", "ooni/dns_injection");
Foo foo = Foo(settings);
foo.begin();
LibIght.loop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment