Updated libraries. Removed dead code
This commit is contained in:
parent
4c40fd38f3
commit
8f9c68a288
11
build.gradle
11
build.gradle
|
@ -38,8 +38,8 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
// this is the only way to also get the source code for IDE auto-complete
|
||||
classpath "gradle.plugin.com.dorkbox:Licensing:1.2.2"
|
||||
classpath "gradle.plugin.com.dorkbox:Licensing:1.2.2:sources"
|
||||
classpath "gradle.plugin.com.dorkbox:Licensing:1.3"
|
||||
classpath "gradle.plugin.com.dorkbox:Licensing:1.3:sources"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,14 +49,13 @@ plugins {
|
|||
id 'signing'
|
||||
|
||||
// close and release on sonatype
|
||||
id 'io.codearte.nexus-staging' version '0.11.0'
|
||||
id 'io.codearte.nexus-staging' version '0.20.0'
|
||||
|
||||
id "com.dorkbox.CrossCompile" version "1.0.1"
|
||||
id "com.dorkbox.VersionUpdate" version "1.4"
|
||||
|
||||
// setup checking for the latest version of a plugin or dependency (and updating the gradle build)
|
||||
id "se.patrikerdes.use-latest-versions" version "0.2.3"
|
||||
id 'com.github.ben-manes.versions' version '0.16.0'
|
||||
}
|
||||
|
||||
// this is the only way to also get the source code for IDE auto-complete
|
||||
|
@ -242,7 +241,7 @@ dependencies {
|
|||
|
||||
api "org.bouncycastle:bcprov-jdk15on:$bcVersion"
|
||||
api "org.bouncycastle:bcpg-jdk15on:$bcVersion"
|
||||
api "org.bouncycastle:bcmail-jdk15on:$bcVersion"
|
||||
api "org.bouncycastle:bcmail-jdk15on:$bcVersion"z
|
||||
api "org.bouncycastle:bctls-jdk15on:$bcVersion"
|
||||
|
||||
api "com.dorkbox:ObjectPool:2.11"
|
||||
|
@ -512,7 +511,7 @@ tasks.withType(PublishToMavenLocal) {
|
|||
/// Run this task, then refresh the gradle project
|
||||
/////////////////////////////
|
||||
task updateWrapper(type: Wrapper) {
|
||||
gradleVersion = '4.10.2'
|
||||
gradleVersion = '5.1'
|
||||
distributionUrl = distributionUrl.replace("bin", "all")
|
||||
setDistributionType(Wrapper.DistributionType.ALL)
|
||||
}
|
||||
|
|
|
@ -22,5 +22,3 @@ for (project in rootProject.children) {
|
|||
assert (project.projectDir.directory)
|
||||
assert (project.buildFile.file)
|
||||
}
|
||||
|
||||
enableFeaturePreview('STABLE_PUBLISHING')
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
package org.handwerkszeug.dns.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import dorkbox.network.dns.records.DnsMessage;
|
||||
import dorkbox.util.NamedThreadFactory;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.oio.OioEventLoopGroup;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.oio.OioDatagramChannel;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public
|
||||
class DNSMessageDecoder extends ChannelInboundHandlerAdapter {
|
||||
|
||||
/**
|
||||
* This is what is called whenever a DNS packet is received. Currently only support UDP packets.
|
||||
* <p>
|
||||
* Calls {@link ChannelHandlerContext#fireChannelRead(Object)} to forward
|
||||
* to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
|
||||
* <p>
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*/
|
||||
@Override
|
||||
public
|
||||
void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof io.netty.channel.socket.DatagramPacket) {
|
||||
ByteBuf content = ((DatagramPacket) msg).content();
|
||||
|
||||
if (content.readableBytes() == 0) {
|
||||
// we can't read this message, there's nothing there!
|
||||
System.err.println("NO CONTENT ");
|
||||
ctx.fireChannelRead(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
DnsMessage msg1 = new DnsMessage(content);
|
||||
|
||||
// should get one from a pool!
|
||||
|
||||
Bootstrap dnsBootstrap = new Bootstrap();
|
||||
|
||||
// setup the thread group to easily ID what the following threads belong to (and their spawned threads...)
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
ThreadGroup nettyGroup = new ThreadGroup(s != null
|
||||
? s.getThreadGroup()
|
||||
: Thread.currentThread()
|
||||
.getThreadGroup(), "DnsClient (Netty)");
|
||||
|
||||
EventLoopGroup group;
|
||||
if (PlatformDependent.isAndroid()) {
|
||||
group = new OioEventLoopGroup(0, new NamedThreadFactory("DnsClient-boss-UDP", nettyGroup));
|
||||
dnsBootstrap.channel(OioDatagramChannel.class);
|
||||
}
|
||||
else {
|
||||
group = new NioEventLoopGroup(2, new NamedThreadFactory("DnsClient-boss-UDP", nettyGroup));
|
||||
dnsBootstrap.channel(NioDatagramChannel.class);
|
||||
}
|
||||
|
||||
dnsBootstrap.group(group);
|
||||
dnsBootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
||||
// dnsBootstrap.handler(new DnsHandler());
|
||||
|
||||
|
||||
|
||||
// sending the question
|
||||
final ChannelFuture future = dnsBootstrap.connect(new InetSocketAddress("8.8.8.8", 53));
|
||||
try {
|
||||
future.await();
|
||||
|
||||
if (future.isSuccess()) {
|
||||
// woo, connected!
|
||||
System.err.println("CONNECTED");
|
||||
// this.dnsServer = dnsServer;
|
||||
}
|
||||
else {
|
||||
System.err.println("CANNOT CONNECT!");
|
||||
// this.dnsServer = null;
|
||||
// Logger logger2 = this.logger;
|
||||
// if (logger2.isDebugEnabled()) {
|
||||
// logger2.error("Could not connect to the DNS server.", this.future.cause());
|
||||
// }
|
||||
// else {
|
||||
// logger2.error("Could not connect to the DNS server.");
|
||||
// }
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Logger logger2 = this.logger;
|
||||
// if (logger2.isDebugEnabled()) {
|
||||
// logger2.error("Could not connect to the DNS server on port {}.", dnsServer.getPort(), e.getCause());
|
||||
// }
|
||||
// else {
|
||||
// logger2.error("Could not connect to the DNS server on port {}.", dnsServer.getPort());
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ClientBootstrap cb = new ClientBootstrap(this.clientChannelFactory);
|
||||
// cb.setOption("broadcast", "false");
|
||||
//
|
||||
// cb.setPipelineFactory(new ChannelPipelineFactory() {
|
||||
// @Override
|
||||
// public
|
||||
// ChannelPipeline getPipeline() throws Exception {
|
||||
// return Channels.pipeline(new ClientHanler(original, e.getChannel(), e.getRemoteAddress()));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// List<SocketAddress> newlist = new ArrayList<SocketAddress>(this.config.getForwarders());
|
||||
// sendRequest(e, original, cb, newlist);
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// protected
|
||||
// void sendRequest(final MessageEvent e, final DNSMessage original, final ClientBootstrap bootstrap, final List<SocketAddress> forwarders) {
|
||||
//
|
||||
// if (0 < forwarders.size()) {
|
||||
// SocketAddress sa = forwarders.remove(0);
|
||||
// LOG.debug("send to {}", sa);
|
||||
//
|
||||
// ChannelFuture f = bootstrap.connect(sa);
|
||||
// ChannelBuffer newone = ChannelBuffers.buffer(512);
|
||||
// DNSMessage msg = new DNSMessage(original);
|
||||
// msg.write(newone);
|
||||
// newone.resetReaderIndex();
|
||||
// final Channel c = f.getChannel();
|
||||
//
|
||||
// if (LOG.isDebugEnabled()) {
|
||||
// LOG.debug("STATUS : [isOpen/isConnected/isWritable {}] {} {}",
|
||||
// new Object[] {new boolean[] {c.isOpen(), c.isConnected(), c.isWritable()}, c.getRemoteAddress(), c.getClass()});
|
||||
// }
|
||||
//
|
||||
// c.write(newone, sa).addListener(new ChannelFutureListener() {
|
||||
// @Override
|
||||
// public
|
||||
// void operationComplete(ChannelFuture future) throws Exception {
|
||||
// LOG.debug("request complete isSuccess : {}", future.isSuccess());
|
||||
// if (future.isSuccess() == false) {
|
||||
// if (0 < forwarders.size()) {
|
||||
// sendRequest(e, original, bootstrap, forwarders);
|
||||
// }
|
||||
// else {
|
||||
// original.header().rcode(RCode.ServFail);
|
||||
// ChannelBuffer buffer = ChannelBuffers.buffer(512);
|
||||
// original.write(buffer);
|
||||
// // close inbound channel
|
||||
// e.getChannel().write(buffer).addListener(ChannelFutureListener.CLOSE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // f.awaitUninterruptibly(30, TimeUnit.SECONDS);
|
||||
// }
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user