mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-24 23:23:08 +00:00
Refactoring
This commit is contained in:
parent
164c9a4155
commit
06ec2537fb
3 changed files with 7 additions and 7 deletions
|
@ -29,7 +29,7 @@ import java.net.InetAddress;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Packet {
|
||||
public class IPv4Packet {
|
||||
private static final String TAG = "NetGuard.Packet";
|
||||
|
||||
private ByteBuffer packet;
|
||||
|
@ -37,10 +37,10 @@ public class Packet {
|
|||
public UDPHeader UDP = null;
|
||||
public TCP TCP = null;
|
||||
|
||||
private Packet() {
|
||||
private IPv4Packet() {
|
||||
}
|
||||
|
||||
public Packet(ByteBuffer buffer) throws IOException {
|
||||
public IPv4Packet(ByteBuffer buffer) throws IOException {
|
||||
packet = buffer;
|
||||
|
||||
try {
|
|
@ -57,11 +57,11 @@ public class LogAdapter extends CursorAdapter {
|
|||
tvIP.setText(whois);
|
||||
|
||||
if (version == 4)
|
||||
if (protocol == Packet.IPv4Header.ICMP)
|
||||
if (protocol == IPv4Packet.IPv4Header.ICMP)
|
||||
tvProtocol.setText("ICMP");
|
||||
else if (protocol == Packet.IPv4Header.TCP)
|
||||
else if (protocol == IPv4Packet.IPv4Header.TCP)
|
||||
tvProtocol.setText("TCP");
|
||||
else if (protocol == Packet.IPv4Header.UDP)
|
||||
else if (protocol == IPv4Packet.IPv4Header.UDP)
|
||||
tvProtocol.setText("UDP");
|
||||
else
|
||||
tvProtocol.setText(protocol < 0 ? "" : Integer.toString(protocol));
|
||||
|
|
|
@ -701,7 +701,7 @@ public class SinkholeService extends VpnService {
|
|||
byte version = (byte) (buffer.get() >> 4);
|
||||
if (version == 4) {
|
||||
buffer.position(0);
|
||||
Packet pkt = new Packet(buffer);
|
||||
IPv4Packet pkt = new IPv4Packet(buffer);
|
||||
Log.i(TAG, "Packet to " + pkt.IPv4.destinationAddress.toString());
|
||||
new DatabaseHelper(SinkholeService.this).insertLog(
|
||||
version,
|
||||
|
|
Loading…
Reference in a new issue