From 3ef28eb83c149ff134df1841d12bcbea3d8fe163 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 28 Apr 2019 12:18:31 +0700 Subject: [PATCH] Update lib version, remove unneeded classes, remove jvm info --- README.md | 2 +- VERSION | 2 +- gradle/configure.gradle | 4 +- .../jxnet/config/SpringJxnetRunnerConfig.java | 2 +- .../src/main/resources/application.properties | 2 +- jxnet-example/build.gradle | 18 +++--- .../autoconfigure/JxnetAutoConfiguration.java | 11 ---- .../JxnetConfigurationProperties.java | 28 +-------- .../autoconfigure/NioAsyncBufferHandler.java | 34 ----------- .../boot/autoconfigure/NioBufferHandler.java | 34 ----------- .../constant/JxnetObjectName.java | 1 - .../DefaultNioBufferHandler.java | 59 ------------------- 12 files changed, 18 insertions(+), 179 deletions(-) delete mode 100644 jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioAsyncBufferHandler.java delete mode 100644 jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioBufferHandler.java delete mode 100644 jxnet-spring-boot-starter-example/src/main/java/com/ardikars/jxnet/spring/boot/starter/example/configuration/DefaultNioBufferHandler.java diff --git a/README.md b/README.md index 888336c3..674fcc51 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Getting Started - Linux (x86/x86_64) - Mac OS - ##### Java Version - - Java 8 (or newer) + - Java 6 (java 8 required if you are using spring-boot) - ##### Dependecies - Windows - Winpcap or Npcap diff --git a/VERSION b/VERSION index d3219766..40414d7b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.5.RC3 \ No newline at end of file +1.5.5.RC4 \ No newline at end of file diff --git a/gradle/configure.gradle b/gradle/configure.gradle index ac376c52..61d9810d 100644 --- a/gradle/configure.gradle +++ b/gradle/configure.gradle @@ -31,8 +31,8 @@ ext { PMD_VERION = '6.10.0' JACOCO_VERSION = '0.8.2' - COMMON_VERSION = '1.2.7.RC5' - JXPACKET_VERSION = '1.2.3.RC4' + COMMON_VERSION = '1.2.7.RELEASE' + JXPACKET_VERSION = '1.2.3.RELEASE' REACTOR_VERSION = 'Californium-RELEASE' JNR_VERSION = '2.1.9' diff --git a/jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/jxnet/config/SpringJxnetRunnerConfig.java b/jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/jxnet/config/SpringJxnetRunnerConfig.java index 9291705e..5a07bbd3 100644 --- a/jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/jxnet/config/SpringJxnetRunnerConfig.java +++ b/jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/jxnet/config/SpringJxnetRunnerConfig.java @@ -31,7 +31,7 @@ * @author Ardika Rommy Sanjaya */ @Configuration("springJxnetRunnerConfig") -@EnablePacket(packetHandlerType = PacketHandlerType.JXPACKET) +@EnablePacket(packetHandlerType = PacketHandlerType.JXPACKET_RAW) public class SpringJxnetRunnerConfig implements JxpacketHandler { @Override diff --git a/jxnet-benchmark/src/main/resources/application.properties b/jxnet-benchmark/src/main/resources/application.properties index 1dc7c76d..53a077e0 100644 --- a/jxnet-benchmark/src/main/resources/application.properties +++ b/jxnet-benchmark/src/main/resources/application.properties @@ -1,4 +1,4 @@ -jxnet.file=${PCAP_FILE:file.pcapng} +jxnet.file=${PCAP_FILE:/tmp/dump.pcap} jxnet.pcapType=offline jxnet.numberOfThread=${NUMBER_OF_THREAD:} diff --git a/jxnet-example/build.gradle b/jxnet-example/build.gradle index dd213cc8..6504eaf3 100644 --- a/jxnet-example/build.gradle +++ b/jxnet-example/build.gradle @@ -6,15 +6,15 @@ description = 'Jxnet example application.' dependencies { - implementation ("com.ardikars.common:common-annotation") - implementation ("com.ardikars.common:common-util") - implementation ("com.ardikars.common:common-net") - implementation ("com.ardikars.common:common-tuple") - implementation ("com.ardikars.common:common-memory") - implementation ("com.ardikars.jxpacket:jxpacket-common:1.2.3.RC") - implementation ("com.ardikars.jxpacket:jxpacket-core:1.2.3.RC") - implementation project (":jxnet-core") - implementation project (":jxnet-context") + compile ("com.ardikars.common:common-annotation") + compile ("com.ardikars.common:common-util") + compile ("com.ardikars.common:common-net") + compile ("com.ardikars.common:common-tuple") + compile ("com.ardikars.common:common-memory") + compile ("com.ardikars.jxpacket:jxpacket-common:1.2.3.RC") + compile ("com.ardikars.jxpacket:jxpacket-core:1.2.3.RC") + compile project (":jxnet-core") + compile project (":jxnet-context") testImplementation ("junit:junit:${JUNIT_VERSION}") testImplementation ("org.mockito:mockito-core:${MOCKITO_VERSION}") } diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java index 87674e51..b66e0a9e 100644 --- a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java +++ b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java @@ -24,7 +24,6 @@ import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.DATALINK_TYPE_BEAN_NAME; import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.ERRBUF_BEAN_NAME; import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.EXECUTOR_SERVICE_BEAN_NAME; -import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.JVM_BEAN_NAME; import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.JXNET_AUTO_CONFIGURATION_BEAN_NAME; import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.MAC_ADDRESS_BEAN_NAME; import static com.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.NETMASK_BEAN_NAME; @@ -36,7 +35,6 @@ import com.ardikars.common.net.Inet4Address; import com.ardikars.common.net.MacAddress; import com.ardikars.common.util.Platforms; -import com.ardikars.common.util.management.Jvm; import com.ardikars.jxnet.DataLinkType; import com.ardikars.jxnet.Jxnet; import com.ardikars.jxnet.Pcap; @@ -343,13 +341,4 @@ public Context context(@Qualifier(PCAP_BUILDER_BEAN_NAME) Pcap.Builder builder, return context; } - /** - * Get {@link Jvm}. - * @return returns {@link Jvm}. - */ - @Bean(JVM_BEAN_NAME) - public Jvm jvm() { - return properties.getJvm(); - } - } diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java index 8f92d3c6..cd4f89f3 100644 --- a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java +++ b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java @@ -19,8 +19,6 @@ import com.ardikars.common.logging.Logger; import com.ardikars.common.logging.LoggerFactory; -import com.ardikars.common.util.management.Jvm; -import com.ardikars.common.util.management.Jvms; import com.ardikars.jxnet.BpfProgram; import com.ardikars.jxnet.DataLinkType; import com.ardikars.jxnet.ImmediateMode; @@ -80,8 +78,6 @@ public class JxnetConfigurationProperties { private Integer numberOfThread; - private Jvm jvm; - /** * Initialize properties. */ @@ -101,7 +97,9 @@ public JxnetConfigurationProperties() { } pcap(); bpf(); - jvm(); + if (numberOfThread == null) { + numberOfThread = Runtime.getRuntime().availableProcessors(); + } log(); } @@ -141,22 +139,6 @@ private void bpf() { } } - private void jvm() { - try { - jvm = Jvms.getJvm(); - if (numberOfThread == null) { - if (jvm.hasJvm()) { - numberOfThread = jvm.getAvailableProcessors(); - } else { - numberOfThread = 0; - } - } - } catch (Exception e) { - jvm = null; - LOGGER.warn(e.getMessage()); - } - } - private void log() { LOGGER.debug("Source : {}", source); LOGGER.debug("Snapshot length : {}", snapshot); @@ -304,8 +286,4 @@ public void setNumberOfThread(Integer numberOfThread) { this.numberOfThread = numberOfThread; } - public Jvm getJvm() { - return jvm; - } - } diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioAsyncBufferHandler.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioAsyncBufferHandler.java deleted file mode 100644 index 75e2d8e8..00000000 --- a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioAsyncBufferHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2015-2018 Jxnet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet.spring.boot.autoconfigure; - -import com.ardikars.common.tuple.Pair; -import com.ardikars.jxnet.PcapPktHdr; - -import java.nio.ByteBuffer; -import java.util.concurrent.Future; - -/** - * Callback function used for capturing packets. - * - * @author Ardika Rommy Sanjaya - * @since 1.5.4 - */ -public interface NioAsyncBufferHandler extends Handler>> { - -} diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioBufferHandler.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioBufferHandler.java deleted file mode 100644 index 31efbf08..00000000 --- a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/NioBufferHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2015-2018 Jxnet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet.spring.boot.autoconfigure; - -import com.ardikars.common.tuple.Pair; -import com.ardikars.jxnet.PcapPktHdr; - -import java.nio.ByteBuffer; -import java.util.concurrent.Future; - -/** - * Callback function used for capturing packets. - * - * @author Ardika Rommy Sanjaya - * @since 1.4.9 - */ -public interface NioBufferHandler extends Handler>> { - -} diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/JxnetObjectName.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/JxnetObjectName.java index 6dcafc9f..adf0f7d2 100644 --- a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/JxnetObjectName.java +++ b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/JxnetObjectName.java @@ -42,7 +42,6 @@ public final class JxnetObjectName { public static final String JXPACKET_ASYNC_RAW_HANDLER_CONFIGURATION_BEAN_NAME = "com.ardikras.jxnet.jxpacketAsyncRawHandlerConfiguration"; public static final String JXPACKET_ASYNC_HANDLER_CONFIGURATION_BEAN_NAME = "com.ardikras.jxnet.jxpacketAsyncHandlerConfiguration"; public static final String PCAP_BUILDER_BEAN_NAME = "com.ardikras.jxnet.pcapBuilder"; - public static final String JVM_BEAN_NAME = "com.ardikras.jxnet.jvm"; private final String prefix; private final String separator; diff --git a/jxnet-spring-boot-starter-example/src/main/java/com/ardikars/jxnet/spring/boot/starter/example/configuration/DefaultNioBufferHandler.java b/jxnet-spring-boot-starter-example/src/main/java/com/ardikars/jxnet/spring/boot/starter/example/configuration/DefaultNioBufferHandler.java deleted file mode 100644 index 573111f9..00000000 --- a/jxnet-spring-boot-starter-example/src/main/java/com/ardikars/jxnet/spring/boot/starter/example/configuration/DefaultNioBufferHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (C) 2015-2018 Jxnet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet.spring.boot.starter.example.configuration; - -import com.ardikars.common.tuple.Pair; -import com.ardikars.jxnet.PcapPktHdr; -import com.ardikars.jxnet.spring.boot.autoconfigure.NioBufferHandler; -//import com.ardikars.jxnet.spring.boot.autoconfigure.annotation.EnablePacket; -//import com.ardikars.jxnet.spring.boot.autoconfigure.constant.PacketHandlerType; -import java.nio.ByteBuffer; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -//import org.springframework.context.annotation.Configuration; - -/** - * Nio buffer configuration. - * - * @author Ardika Rommy Sanjaya - * @since 1.4.9 - */ -//@EnablePacket(packetHandlerType = PacketHandlerType.NIO_BUFFER) -//@Configuration -public class DefaultNioBufferHandler implements NioBufferHandler { - - private static final Logger LOGGER = LoggerFactory.getLogger(DefaultJxpacketHandler.class.getName()); - - private static final String PRETTY_FOOTER = "+---------------------------------------------------" - + "--------------------------------------------------+"; - - private void print(Pair packet) { - LOGGER.info("Pcap packet header : {}", packet.getLeft()); - LOGGER.info("Packet header : {}", packet.getRight()); - LOGGER.info(PRETTY_FOOTER); - } - - @Override - public void next(String argument, Future> packet) throws ExecutionException, InterruptedException { - LOGGER.info("User argument : {}", argument); - print(packet.get()); - } - -}