Skip to content

Commit

Permalink
feat: Update Zerotier core to 1.10.x (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaass authored Mar 27, 2023
2 parents faff15a + dd0bf68 commit 02f4953
Show file tree
Hide file tree
Showing 68 changed files with 2,613 additions and 1,798 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/zerotier/sdk/DataStoreGetListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
*/

package com.zerotier.sdk;

public interface DataStoreGetListener {
Expand All @@ -48,7 +49,7 @@ public interface DataStoreGetListener {
* @param out_buffer buffer to put the object in
* @return size of the object
*/
public long onDataStoreGet(
long onDataStoreGet(
String name,
byte[] out_buffer);
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/zerotier/sdk/DataStorePutListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
*/

package com.zerotier.sdk;

public interface DataStorePutListener {
Expand All @@ -43,7 +44,7 @@ public interface DataStorePutListener {
* @param secure set to user read/write only.
* @return 0 on success.
*/
public int onDataStorePut(
int onDataStorePut(
String name,
byte[] buffer,
boolean secure);
Expand All @@ -54,6 +55,6 @@ public int onDataStorePut(
* @param name Object name
* @return 0 on success.
*/
public int onDelete(
int onDelete(
String name);
}
70 changes: 63 additions & 7 deletions app/src/main/java/com/zerotier/sdk/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,32 @@

package com.zerotier.sdk;

/**
* Status codes sent to status update callback when things happen
*
* Defined in ZeroTierOne.h as ZT_Event
*/
public enum Event {

/**
* Node has been initialized
*
* This is the first event generated, and is always sent. It may occur
* before Node's constructor returns.
*/
EVENT_UP,
EVENT_UP(0),

/**
* Node is offline -- network does not seem to be reachable by any available strategy
*/
EVENT_OFFLINE,
EVENT_OFFLINE(1),

/**
* Node is online -- at least one upstream node appears reachable
*
* Meta-data: none
*/
EVENT_ONLINE,
EVENT_ONLINE(2),

/**
* Node is shutting down
Expand All @@ -55,7 +61,7 @@ public enum Event {
* It's done for convenience, since cleaning up other state in the event
* handler may appear more idiomatic.</p>
*/
EVENT_DOWN,
EVENT_DOWN(3),

/**
* Your identity has collided with another node's ZeroTier address
Expand Down Expand Up @@ -85,7 +91,7 @@ public enum Event {
* condition is a good way to make sure it never arises. It's like how
* umbrellas prevent rain and smoke detectors prevent fires. They do, right?</p>
*/
EVENT_FATAL_ERROR_IDENTITY_COLLISION,
EVENT_FATAL_ERROR_IDENTITY_COLLISION(4),

/**
* Trace (debugging) message
Expand All @@ -94,5 +100,55 @@ public enum Event {
*
* <p>Meta-data: {@link String}, TRACE message</p>
*/
EVENT_TRACE
}
EVENT_TRACE(5),

/**
* VERB_USER_MESSAGE received
*
* These are generated when a VERB_USER_MESSAGE packet is received via
* ZeroTier VL1.
*/
EVENT_USER_MESSAGE(6),

/**
* Remote trace received
*
* These are generated when a VERB_REMOTE_TRACE is received. Note
* that any node can fling one of these at us. It is your responsibility
* to filter and determine if it's worth paying attention to. If it's
* not just drop it. Most nodes that are not active controllers ignore
* these, and controllers only save them if they pertain to networks
* with remote tracing enabled.
*/
EVENT_REMOTE_TRACE(7);

@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final int id;

Event(int id) {
this.id = id;
}

public static Event fromInt(int id) {
switch (id) {
case 0:
return EVENT_UP;
case 1:
return EVENT_OFFLINE;
case 2:
return EVENT_ONLINE;
case 3:
return EVENT_DOWN;
case 4:
return EVENT_FATAL_ERROR_IDENTITY_COLLISION;
case 5:
return EVENT_TRACE;
case 6:
return EVENT_USER_MESSAGE;
case 7:
return EVENT_REMOTE_TRACE;
default:
throw new RuntimeException("Unhandled value: " + id);
}
}
}
8 changes: 3 additions & 5 deletions app/src/main/java/com/zerotier/sdk/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@

package com.zerotier.sdk;

import java.net.InetSocketAddress;
import java.lang.String;

/**
* Interface to handle callbacks for ZeroTier One events.
*/
public interface EventListener {

/**
* Callback for events with no other associated metadata
*
* @param event {@link Event} enum
*/
public void onEvent(Event event);
void onEvent(Event event);

/**
* Trace messages
Expand All @@ -48,5 +46,5 @@ public interface EventListener {
*
* @param message the trace message
*/
public void onTrace(String message);
void onTrace(String message);
}
93 changes: 0 additions & 93 deletions app/src/main/java/com/zerotier/sdk/NativeUtils.java

This file was deleted.

Loading

0 comments on commit 02f4953

Please sign in to comment.