test_class.declarator: service
test_class.modifier: private
test_class.original_string: private AdVpnService service;
test_class.type: AdVpnService
test_class.var_name: service
test_class.declarator: thread
test_class.modifier: private
test_class.original_string: private AdVpnThread thread;
test_class.type: AdVpnThread
test_class.var_name: thread
test_class.declarator: config
test_class.modifier: private
test_class.original_string: private Configuration config;
test_class.type: Configuration
test_class.var_name: config
test_class.declarator: builder
test_class.modifier: private
test_class.original_string: private VpnService.Builder builder;
test_class.type: VpnService.Builder
test_class.var_name: builder
test_class.declarator: serversAdded
test_class.modifier: private
test_class.original_string: private List<InetAddress> serversAdded;
test_class.type: List<InetAddress>
test_class.var_name: serversAdded
test_class.file: app/src/test/java/org/jak_linux/dns66/vpn/AdVpnThreadTest.java
test_class.identifier: AdVpnThreadTest
test_case.body: @Test
      public void testConfigurePackages() throws Exception {
          final List<String> disallowed = new ArrayList<>();
          final List<String> allowed = new ArrayList<>();
          when(builder.addDisallowedApplication(anyString())).thenAnswer(new Answer<Object>() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                  disallowed.add(invocation.getArgumentAt(0, String.class));
                  return null;
              }
          });
          when(builder.addAllowedApplication(anyString())).thenAnswer(new Answer<Object>() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                  allowed.add(invocation.getArgumentAt(0, String.class));
                  return null;
              }
          });
  
          // We are defaulting to disallow: allow all allowed packages.
          allowed.clear();
          disallowed.clear();
          config.whitelist.defaultMode = Configuration.Whitelist.DEFAULT_MODE_NOT_ON_VPN;
          thread.configurePackages(builder, config);
          assertTrue(allowed.contains("onVpn"));
          assertEquals(new ArrayList<String>(), disallowed);
  
          // We are defaulting to allow: deny all non-allowed packages.
          allowed.clear();
          disallowed.clear();
          config.whitelist.defaultMode = Configuration.Whitelist.DEFAULT_MODE_ON_VPN;
          thread.configurePackages(builder, config);
          assertTrue(disallowed.contains("notOnVpn"));
          assertEquals(new ArrayList<String>(), allowed);
  
          // Intelligent is like allow, it only disallows system apps
          allowed.clear();
          disallowed.clear();
          config.whitelist.defaultMode = Configuration.Whitelist.DEFAULT_MODE_INTELLIGENT;
          thread.configurePackages(builder, config);
          assertTrue(disallowed.contains("notOnVpn"));
          assertEquals(new ArrayList<String>(), allowed);
  
      }
test_case.class_method_signature: AdVpnThreadTest.testConfigurePackages()
test_case.full_signature: @Test public void testConfigurePackages()
test_case.identifier: testConfigurePackages
test_case.invocations: thenAnswer when addDisallowedApplication anyString add getArgumentAt thenAnswer when addAllowedApplication anyString add getArgumentAt clear clear configurePackages assertTrue contains assertEquals clear clear configurePackages assertTrue contains assertEquals clear clear configurePackages assertTrue contains assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testConfigurePackages()
focal_class.declarator: TAG = "AdVpnThread"
focal_class.modifier: private static final
focal_class.original_string: private static final String TAG = "AdVpnThread";
focal_class.type: String
focal_class.var_name: TAG
focal_class.declarator: MIN_RETRY_TIME = 5
focal_class.modifier: private static final
focal_class.original_string: private static final int MIN_RETRY_TIME = 5;
focal_class.type: int
focal_class.var_name: MIN_RETRY_TIME
focal_class.declarator: MAX_RETRY_TIME = 2 * 60
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_RETRY_TIME = 2 * 60;
focal_class.type: int
focal_class.var_name: MAX_RETRY_TIME
focal_class.declarator: RETRY_RESET_SEC = 60
focal_class.modifier: private static final
focal_class.original_string: private static final long RETRY_RESET_SEC = 60;
focal_class.type: long
focal_class.var_name: RETRY_RESET_SEC
focal_class.declarator: DNS_MAXIMUM_WAITING = 1024
focal_class.modifier: private static final
focal_class.original_string: private static final int DNS_MAXIMUM_WAITING = 1024;
focal_class.type: int
focal_class.var_name: DNS_MAXIMUM_WAITING
focal_class.declarator: DNS_TIMEOUT_SEC = 10
focal_class.modifier: private static final
focal_class.original_string: private static final long DNS_TIMEOUT_SEC = 10;
focal_class.type: long
focal_class.var_name: DNS_TIMEOUT_SEC
focal_class.declarator: upstreamDnsServers = new ArrayList<>()
focal_class.modifier: final
focal_class.original_string: final ArrayList<InetAddress> upstreamDnsServers = new ArrayList<>();
focal_class.type: ArrayList<InetAddress>
focal_class.var_name: upstreamDnsServers
focal_class.declarator: vpnService
focal_class.modifier: private final
focal_class.original_string: private final VpnService vpnService;
focal_class.type: VpnService
focal_class.var_name: vpnService
focal_class.declarator: notify
focal_class.modifier: private final
focal_class.original_string: private final Notify notify;
focal_class.type: Notify
focal_class.var_name: notify
focal_class.declarator: deviceWrites = new LinkedList<>()
focal_class.modifier: private final
focal_class.original_string: private final Queue<byte[]> deviceWrites = new LinkedList<>();
focal_class.type: Queue<byte[]>
focal_class.var_name: deviceWrites
focal_class.declarator: dnsIn = new WospList()
focal_class.modifier: private final
focal_class.original_string: private final WospList dnsIn = new WospList();
focal_class.type: WospList
focal_class.var_name: dnsIn
focal_class.declarator: dnsPacketProxy = new DnsPacketProxy(this)
focal_class.modifier: private final
focal_class.original_string: private final DnsPacketProxy dnsPacketProxy = new DnsPacketProxy(this);
focal_class.type: DnsPacketProxy
focal_class.var_name: dnsPacketProxy
focal_class.declarator: vpnWatchDog = new VpnWatchdog()
focal_class.modifier: private final
focal_class.original_string: private final VpnWatchdog vpnWatchDog = new VpnWatchdog();
focal_class.type: VpnWatchdog
focal_class.var_name: vpnWatchDog
focal_class.declarator: thread = null
focal_class.modifier: private
focal_class.original_string: private Thread thread = null;
focal_class.type: Thread
focal_class.var_name: thread
focal_class.declarator: mBlockFd = null
focal_class.modifier: private
focal_class.original_string: private FileDescriptor mBlockFd = null;
focal_class.type: FileDescriptor
focal_class.var_name: mBlockFd
focal_class.declarator: mInterruptFd = null
focal_class.modifier: private
focal_class.original_string: private FileDescriptor mInterruptFd = null;
focal_class.type: FileDescriptor
focal_class.var_name: mInterruptFd
focal_class.declarator: pcap4jFactoryClearCacheCounter = 0
focal_class.modifier: private
focal_class.original_string: private int pcap4jFactoryClearCacheCounter = 0;
focal_class.type: int
focal_class.var_name: pcap4jFactoryClearCacheCounter
focal_class.file: app/src/main/java/org/jak_linux/dns66/vpn/AdVpnThread.java
focal_class.identifier: AdVpnThread
focal_class.interfaces: implements Runnable, DnsPacketProxy.EventLoop
focal_class.class_method_signature: AdVpnThread.AdVpnThread(VpnService vpnService, Notify notify)
focal_class.full_signature: public  AdVpnThread(VpnService vpnService, Notify notify)
focal_class.identifier: AdVpnThread
focal_class.modifiers: public
focal_class.parameters: (VpnService vpnService, Notify notify)
focal_class.signature:  AdVpnThread(VpnService vpnService, Notify notify)
focal_class.class_method_signature: AdVpnThread.getDnsServers(Context context)
focal_class.full_signature: private static List<InetAddress> getDnsServers(Context context)
focal_class.identifier: getDnsServers
focal_class.modifiers: private static
focal_class.parameters: (Context context)
focal_class.return: List<InetAddress>
focal_class.signature: List<InetAddress> getDnsServers(Context context)
focal_class.class_method_signature: AdVpnThread.startThread()
focal_class.full_signature: public void startThread()
focal_class.identifier: startThread
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void startThread()
focal_class.class_method_signature: AdVpnThread.stopThread()
focal_class.full_signature: public void stopThread()
focal_class.identifier: stopThread
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stopThread()
focal_class.class_method_signature: AdVpnThread.run()
focal_class.full_signature: @Override public synchronized void run()
focal_class.identifier: run
focal_class.modifiers: @Override public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: AdVpnThread.runVpn()
focal_class.full_signature: private void runVpn()
focal_class.identifier: runVpn
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void runVpn()
focal_class.class_method_signature: AdVpnThread.doOne(FileInputStream inputStream, FileOutputStream outFd, byte[] packet)
focal_class.full_signature: private boolean doOne(FileInputStream inputStream, FileOutputStream outFd, byte[] packet)
focal_class.identifier: doOne
focal_class.modifiers: private
focal_class.parameters: (FileInputStream inputStream, FileOutputStream outFd, byte[] packet)
focal_class.return: boolean
focal_class.signature: boolean doOne(FileInputStream inputStream, FileOutputStream outFd, byte[] packet)
focal_class.class_method_signature: AdVpnThread.writeToDevice(FileOutputStream outFd)
focal_class.full_signature: private void writeToDevice(FileOutputStream outFd)
focal_class.identifier: writeToDevice
focal_class.modifiers: private
focal_class.parameters: (FileOutputStream outFd)
focal_class.return: void
focal_class.signature: void writeToDevice(FileOutputStream outFd)
focal_class.class_method_signature: AdVpnThread.readPacketFromDevice(FileInputStream inputStream, byte[] packet)
focal_class.full_signature: private void readPacketFromDevice(FileInputStream inputStream, byte[] packet)
focal_class.identifier: readPacketFromDevice
focal_class.modifiers: private
focal_class.parameters: (FileInputStream inputStream, byte[] packet)
focal_class.return: void
focal_class.signature: void readPacketFromDevice(FileInputStream inputStream, byte[] packet)
focal_class.class_method_signature: AdVpnThread.forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket)
focal_class.full_signature: public void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket)
focal_class.identifier: forwardPacket
focal_class.modifiers: public
focal_class.parameters: (DatagramPacket outPacket, IpPacket parsedPacket)
focal_class.return: void
focal_class.signature: void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket)
focal_class.class_method_signature: AdVpnThread.handleRawDnsResponse(IpPacket parsedPacket, DatagramSocket dnsSocket)
focal_class.full_signature: private void handleRawDnsResponse(IpPacket parsedPacket, DatagramSocket dnsSocket)
focal_class.identifier: handleRawDnsResponse
focal_class.modifiers: private
focal_class.parameters: (IpPacket parsedPacket, DatagramSocket dnsSocket)
focal_class.return: void
focal_class.signature: void handleRawDnsResponse(IpPacket parsedPacket, DatagramSocket dnsSocket)
focal_class.class_method_signature: AdVpnThread.queueDeviceWrite(IpPacket ipOutPacket)
focal_class.full_signature: public void queueDeviceWrite(IpPacket ipOutPacket)
focal_class.identifier: queueDeviceWrite
focal_class.modifiers: public
focal_class.parameters: (IpPacket ipOutPacket)
focal_class.return: void
focal_class.signature: void queueDeviceWrite(IpPacket ipOutPacket)
focal_class.class_method_signature: AdVpnThread.newDNSServer(VpnService.Builder builder, String format, byte[] ipv6Template, InetAddress addr)
focal_class.full_signature:  void newDNSServer(VpnService.Builder builder, String format, byte[] ipv6Template, InetAddress addr)
focal_class.identifier: newDNSServer
focal_class.parameters: (VpnService.Builder builder, String format, byte[] ipv6Template, InetAddress addr)
focal_class.return: void
focal_class.signature: void newDNSServer(VpnService.Builder builder, String format, byte[] ipv6Template, InetAddress addr)
focal_class.class_method_signature: AdVpnThread.configurePackages(VpnService.Builder builder, Configuration config)
focal_class.full_signature:  void configurePackages(VpnService.Builder builder, Configuration config)
focal_class.identifier: configurePackages
focal_class.parameters: (VpnService.Builder builder, Configuration config)
focal_class.return: void
focal_class.signature: void configurePackages(VpnService.Builder builder, Configuration config)
focal_class.class_method_signature: AdVpnThread.configure()
focal_class.full_signature: private ParcelFileDescriptor configure()
focal_class.identifier: configure
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ParcelFileDescriptor
focal_class.signature: ParcelFileDescriptor configure()
focal_class.class_method_signature: AdVpnThread.hasIpV6Servers(Configuration config, List<InetAddress> dnsServers)
focal_class.full_signature:  boolean hasIpV6Servers(Configuration config, List<InetAddress> dnsServers)
focal_class.identifier: hasIpV6Servers
focal_class.parameters: (Configuration config, List<InetAddress> dnsServers)
focal_class.return: boolean
focal_class.signature: boolean hasIpV6Servers(Configuration config, List<InetAddress> dnsServers)
focal_method.body: void configurePackages(VpnService.Builder builder, Configuration config) {
          Set<String> allowOnVpn = new HashSet<>();
          Set<String> doNotAllowOnVpn = new HashSet<>();
  
          config.whitelist.resolve(vpnService.getPackageManager(), allowOnVpn, doNotAllowOnVpn);
  
          if (config.whitelist.defaultMode == Configuration.Whitelist.DEFAULT_MODE_NOT_ON_VPN) {
              for (String app : allowOnVpn) {
                  try {
                      Log.d(TAG, "configure: Allowing " + app + " to use the DNS VPN");
                      builder.addAllowedApplication(app);
                  } catch (Exception e) {
                      Log.w(TAG, "configure: Cannot disallow", e);
                  }
              }
          } else {
              for (String app : doNotAllowOnVpn) {
                  try {
                      Log.d(TAG, "configure: Disallowing " + app + " from using the DNS VPN");
                      builder.addDisallowedApplication(app);
                  } catch (Exception e) {
                      Log.w(TAG, "configure: Cannot disallow", e);
                  }
              }
          }
      }
focal_method.class_method_signature: AdVpnThread.configurePackages(VpnService.Builder builder, Configuration config)
focal_method.full_signature:  void configurePackages(VpnService.Builder builder, Configuration config)
focal_method.identifier: configurePackages
focal_method.invocations: resolve getPackageManager d addAllowedApplication w d addDisallowedApplication w
focal_method.parameters: (VpnService.Builder builder, Configuration config)
focal_method.return: void
focal_method.signature: void configurePackages(VpnService.Builder builder, Configuration config)