Example usage for io.vertx.core.net ProxyType SOCKS5

List of usage examples for io.vertx.core.net ProxyType SOCKS5

Introduction

In this page you can find the example usage for io.vertx.core.net ProxyType SOCKS5.

Prototype

ProxyType SOCKS5

To view the source code for io.vertx.core.net ProxyType SOCKS5.

Click Source Link

Document

SOCSK5 tcp proxy

Usage

From source file:examples.HTTPExamples.java

License:Open Source License

public void example59(Vertx vertx) {

    HttpClientOptions options = new HttpClientOptions()
            .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5).setHost("localhost").setPort(1080)
                    .setUsername("username").setPassword("secret"));
    HttpClient client = vertx.createHttpClient(options);

}

From source file:examples.NetExamples.java

License:Open Source License

public void example47(Vertx vertx) {
    NetClientOptions options = new NetClientOptions()
            .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5).setHost("localhost").setPort(1080)
                    .setUsername("username").setPassword("secret"));
    NetClient client = vertx.createNetClient(options);
}

From source file:org.schors.flibot.FliBot.java

License:Open Source License

@Override
public void start() {

    cm = new CommandManager().addCommand(new GetAuthorCommand()).addCommand(new GetBookCommand())
            .addCommand(new CatalogCommand()).addCommand(new RegisterUserCommand())
            .addCommand(new UnregisterUserCommand()).addCommand(new DownloadCommand())
            .addCommand(new DownloadZipCommand()).addCommand(new GetCmdCommand())
            .setDefaultCommand(new DefaultCommand());

    db = DBService.createProxy(vertx, "db-service");
    urlCache = CacheBuilder.newBuilder().maximumSize(1000).build();

    boolean usetor = config().getBoolean("usetor");

    HttpClientOptions httpOptions = new HttpClientOptions().setTrustAll(true).setIdleTimeout(50)
            .setMaxPoolSize(100).setDefaultHost(usetor ? rootOPDStor : rootOPDShttp).setDefaultPort(80)
            .setLogActivity(true);//from  w w  w .j a v  a  2  s  . c  o  m

    if (usetor) {
        httpOptions.setProxyOptions(
                new ProxyOptions().setType(ProxyType.SOCKS5).setHost(config().getString("torhost"))
                        .setPort(Integer.valueOf(config().getString("torport"))));
    }
    httpclient = vertx.createHttpClient(httpOptions);

    TelegramOptions telegramOptions = new TelegramOptions().setBotName(config().getString("name"))
            .setBotToken(config().getString("token"));

    bot = TelegramBot.create(vertx, telegramOptions, cm).receiver(new LongPollingReceiver().onUpdate(update -> {
        if (update.hasMessage() && update.getMessage().hasText()) {
            sendBusy(update);
            String text = update.getMessage().getText();
            String userName = update.getMessage().getFrom().getUserName();
            log.warn("onUpdate: " + text + ", " + userName);
            db.isRegisterdUser(userName, registrationRes -> {
                if (registrationRes.succeeded() && registrationRes.result().getBoolean("res")) {
                    cm.execute(text, cm.createContext(update));
                } else {
                    sendReply(update, "I do not talk to strangers");
                }
            });
        }
    })).addFacility(Util.HTTP_CLIENT, httpclient).addFacility(Util.CACHE, urlCache)
            .addFacility(Util.SEARCHES, searches).addFacility(Util.DB, db).addFacility(Util.CONFIG, config())
            .start();
}