diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-06-03 18:35:38 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-06-03 18:35:38 -0700 |
commit | 8fb9df97511532a28ac8225282318dd1f31be0e4 (patch) | |
tree | ee369c8232124b5590bedf7867553dfc7059ead0 /java/src/com/zerotier | |
parent | 4c687fca45c85c9dfa4e39d5b7b4fc251b05237d (diff) | |
download | infinitytier-8fb9df97511532a28ac8225282318dd1f31be0e4.tar.gz infinitytier-8fb9df97511532a28ac8225282318dd1f31be0e4.zip |
delete dead test code
Diffstat (limited to 'java/src/com/zerotier')
-rw-r--r-- | java/src/com/zerotier/one/AndroidFileProvider.java | 43 | ||||
-rw-r--r-- | java/src/com/zerotier/one/DataStore.java | 73 | ||||
-rw-r--r-- | java/src/com/zerotier/one/DataStoreFileProvider.java | 12 | ||||
-rw-r--r-- | java/src/com/zerotier/one/JavaFileProvider.java | 46 | ||||
-rw-r--r-- | java/src/com/zerotier/one/OneService.java | 204 |
5 files changed, 0 insertions, 378 deletions
diff --git a/java/src/com/zerotier/one/AndroidFileProvider.java b/java/src/com/zerotier/one/AndroidFileProvider.java deleted file mode 100644 index 0988f9df..00000000 --- a/java/src/com/zerotier/one/AndroidFileProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.zerotier.one; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import android.content.Context; -import android.util.Log; - -public class AndroidFileProvider implements DataStoreFileProvider { - private static final String TAG = "AndroidFileProvider"; - - Context _ctx; - - public AndroidFileProvider(Context ctx) { - this._ctx = ctx; - } - - @Override - public FileInputStream getInputFileStream(String name) - throws FileNotFoundException { - Log.d(TAG, "Returning FileInputStream for: " + name); - return _ctx.openFileInput(name); - } - - @Override - public FileOutputStream getOutputFileStream(String name) - throws FileNotFoundException { - Log.d(TAG, "Returning FileOutputStream for: " + name); - return _ctx.openFileOutput(name, Context.MODE_PRIVATE); - } - - @Override - public void deleteFile(String name) throws IOException { - boolean success = _ctx.deleteFile(name); - if(!success) - { - throw new IOException("Unable to delete file."); - } - } - -} diff --git a/java/src/com/zerotier/one/DataStore.java b/java/src/com/zerotier/one/DataStore.java deleted file mode 100644 index d15b2d3d..00000000 --- a/java/src/com/zerotier/one/DataStore.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.zerotier.one; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import com.zerotier.sdk.DataStoreGetListener; -import com.zerotier.sdk.DataStorePutListener; - -public class DataStore implements DataStoreGetListener, DataStorePutListener { - - private DataStoreFileProvider _provider; - - public DataStore(DataStoreFileProvider provider) { - this._provider = provider; - } - - @Override - public int onDataStorePut(String name, byte[] buffer, boolean secure) { - System.out.println("Writing File: " + name); - try { - FileOutputStream fos = _provider.getOutputFileStream(name); - fos.write(buffer); - fos.close(); - return 0; - } catch (FileNotFoundException fnf) { - fnf.printStackTrace(); - return -1; - } catch (IOException io) { - io.printStackTrace(); - return -2; - } - } - - @Override - public int onDelete(String name) { - System.out.println("Deleting File: " + name); - try { - _provider.deleteFile(name); - return 0; - } catch (IOException ex) { - ex.printStackTrace(); - return -1; - } - } - - @Override - public long onDataStoreGet(String name, byte[] out_buffer, - long bufferIndex, long[] out_objectSize) { - System.out.println("Reading File: " + name); - try { - FileInputStream fin = _provider.getInputFileStream(name); - out_objectSize[0] = fin.getChannel().size(); - if(bufferIndex > 0) - { - fin.skip(bufferIndex); - } - int read = fin.read(out_buffer); - fin.close(); - return read; - } catch (FileNotFoundException fnf) { - // Can't read a file that doesn't exist! - out_objectSize[0] = 0; - return 0; - } catch (IOException io) { - io.printStackTrace(); - return -2; - } - } - - -} diff --git a/java/src/com/zerotier/one/DataStoreFileProvider.java b/java/src/com/zerotier/one/DataStoreFileProvider.java deleted file mode 100644 index ffe078eb..00000000 --- a/java/src/com/zerotier/one/DataStoreFileProvider.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.zerotier.one; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -public interface DataStoreFileProvider { - FileInputStream getInputFileStream(String name) throws FileNotFoundException; - FileOutputStream getOutputFileStream(String name) throws FileNotFoundException; - void deleteFile(String name) throws IOException; -} diff --git a/java/src/com/zerotier/one/JavaFileProvider.java b/java/src/com/zerotier/one/JavaFileProvider.java deleted file mode 100644 index 41889e2f..00000000 --- a/java/src/com/zerotier/one/JavaFileProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.zerotier.one; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -public class JavaFileProvider implements DataStoreFileProvider { - private String _path; - - public JavaFileProvider(String path) { - this._path = path; - } - - @Override - public FileInputStream getInputFileStream(String name) - throws FileNotFoundException { - File f = new File(_path + File.separator + name); - return new FileInputStream(f); - } - - @Override - public FileOutputStream getOutputFileStream(String name) - throws FileNotFoundException { - File f = new File(_path + File.separator + name); - if(!f.exists()) - { - try { - f.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return new FileOutputStream(f); - } - - @Override - public void deleteFile(String name) throws IOException { - File f = new File(_path + File.separator + name); - boolean success = f.delete(); - if(!success) { - throw new IOException("Unable to delete file: " + _path + File.pathSeparator + name); - } - } -} diff --git a/java/src/com/zerotier/one/OneService.java b/java/src/com/zerotier/one/OneService.java deleted file mode 100644 index 1d3e34c8..00000000 --- a/java/src/com/zerotier/one/OneService.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2015 ZeroTier, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 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 <http://www.gnu.org/licenses/>. - * - * -- - * - * ZeroTier may be used and distributed under the terms of the GPLv3, which - * are available at: http://www.gnu.org/licenses/gpl-3.0.html - * - * If you would like to embed ZeroTier into a commercial application or - * redistribute it in a modified binary form, please contact ZeroTier Networks - * LLC. Start here: http://www.zerotier.com/ - */ - - -package com.zerotier.one; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.SocketException; -import java.net.SocketTimeoutException; - -import com.zerotier.sdk.Event; -import com.zerotier.sdk.EventListener; -import com.zerotier.sdk.Node; -import com.zerotier.sdk.PacketSender; -import com.zerotier.sdk.ResultCode; -import com.zerotier.sdk.Version; -import com.zerotier.sdk.VirtualNetworkConfig; -import com.zerotier.sdk.VirtualNetworkConfigListener; -import com.zerotier.sdk.VirtualNetworkConfigOperation; -import com.zerotier.sdk.VirtualNetworkFrameListener; - -public class OneService extends Thread implements Runnable, PacketSender, - EventListener, VirtualNetworkConfigListener, - VirtualNetworkFrameListener { - private Node _node; - private int _port; - - private DatagramSocket _udpSocket; - private ServerSocket _tcpSocket; - private DataStore _ds; - private long _nextBackgroundTaskDeadline = 0; - - private final Thread _udpReceiveThread = new Thread() { - @Override - public void run() { - try { - long[] bgtask = new long[1]; - byte[] buffer = new byte[16384]; - while(true) { - - bgtask[0] = 0; - DatagramPacket p = new DatagramPacket(buffer, buffer.length); - - try { - _udpSocket.receive(p); - if(p.getLength() > 0) - { - System.out.println("Got Data From: " + p.getAddress().toString() +":" + p.getPort()); - - _node.processWirePacket(System.currentTimeMillis(), new InetSocketAddress(p.getAddress(), p.getPort()), p.getData(), bgtask); - _nextBackgroundTaskDeadline = bgtask[0]; - } - } catch (SocketTimeoutException e) {} - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }; - - - public OneService(DataStoreFileProvider prov, int port) { - this._port = port; - this._ds = new DataStore(prov); - - try { - _udpSocket = new DatagramSocket(_port); - _udpSocket.setSoTimeout(100); - _tcpSocket = new ServerSocket(); - _tcpSocket.bind(new InetSocketAddress("127.0.0.1", _port)); - } catch (SocketException e) { - e.printStackTrace(); - return; - } catch (IOException e) { - e.printStackTrace(); - return; - } - - _udpReceiveThread.start(); - - _node = new Node( - System.currentTimeMillis(), - _ds, - _ds, - this, - this, - this, - this); - } - - @Override - public void run() { - if(_node == null) - return; - - while(true) { - try { - - long dl = _nextBackgroundTaskDeadline; - long now = System.currentTimeMillis(); - - if (dl <= now) { - long[] returnDeadline = {0}; - ResultCode rc = _node.processBackgroundTasks(now, returnDeadline); - _nextBackgroundTaskDeadline = returnDeadline[0]; - - if(rc != ResultCode.RESULT_OK) { - System.out.println(rc.toString()); - } - } - - long delay = (dl > now) ? (dl - now) : 100; - Thread.sleep(delay); - - } catch (Exception ex) { - System.out.println("Exception in run loop: " + ex.getMessage()); - ex.printStackTrace(); - } - } - } - - @Override - public int onSendPacketRequested(InetSocketAddress addr, byte[] packetData) { - System.out.println("onSendPacketRequested to: " + addr.getHostString() +":"+ addr.getPort() + " "); - - if(_udpSocket == null) - return -1; - try { - DatagramPacket p = new DatagramPacket(packetData, packetData.length, addr); - _udpSocket.send(p); - System.out.println("Sent"); - } catch (Exception e) { - System.out.println("Error sending datagram: " + e.getMessage()); - return -1; - } - return 0; - } - - @Override - public void onVirtualNetworkFrame(long nwid, long srcMac, long destMac, - long etherType, long vlanId, byte[] frameData) { - // TODO Auto-generated method stub - - } - - @Override - public int onNetworkConfigurationUpdated(long nwid, - VirtualNetworkConfigOperation op, VirtualNetworkConfig config) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void onEvent(Event event) { - // TODO Auto-generated method stub - - } - - @Override - public void onNetworkError(Event event, InetSocketAddress source) { - // TODO Auto-generated method stub - - } - - @Override - public void onOutOfDate(Version newVersion) { - // TODO Auto-generated method stub - - } - - @Override - public void onTrace(String message) { - // TODO Auto-generated method stub - - } -} |