Package net.windwards.dnsfrontend.client

Source Code of net.windwards.dnsfrontend.client.EchoClient

package net.windwards.dnsfrontend.client;


import net.windwards.dnsfrontend.dialog.Request;
import net.windwards.dnsfrontend.dialog.Update;

import java.util.Random;

public class EchoClient {
    public static void main(String... args) throws Exception {
        final Client client = new Client();
        client.setVerbose(true);
        client.addReceiver(new Recipient() {
            Random random = new Random();
            @Override
            public void receive(Request request) {
                Update update = new Update();
                update.name = request.name;
                update.moniker = request.moniker;
                if(request.name.contains("6")) {
                    update.family = "ipv6";
                    update.address = "2002:53fe:52a1:7::" + Integer.toHexString(random.nextInt(65535));
                } else {
                    update.family = "ipv4";
                    update.address = "127.0." + random.nextInt(256) + "." + random.nextInt(256);
                }

                try {
                    client.send(update);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        client.connect();
    }
}
TOP

Related Classes of net.windwards.dnsfrontend.client.EchoClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.