Skip to content

Commit

Permalink
feat: Update Zerotier core to 1.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaass committed Sep 16, 2023
1 parent c7cff8f commit 99e7c71
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,29 @@
import com.zerotier.sdk.Event;
import com.zerotier.sdk.EventListener;
import com.zerotier.sdk.Node;
import com.zerotier.sdk.NodeException;
import com.zerotier.sdk.ResultCode;
import com.zerotier.sdk.VirtualNetworkConfig;
import com.zerotier.sdk.VirtualNetworkConfigListener;
import com.zerotier.sdk.VirtualNetworkConfigOperation;
import com.zerotier.sdk.VirtualNetworkStatus;

import net.kaaass.zerotierfix.ZerotierFixApplication;
import net.kaaass.zerotierfix.R;
import net.kaaass.zerotierfix.ZerotierFixApplication;
import net.kaaass.zerotierfix.events.AfterJoinNetworkEvent;
import net.kaaass.zerotierfix.events.ErrorEvent;
import net.kaaass.zerotierfix.events.IsServiceRunningReplyEvent;
import net.kaaass.zerotierfix.events.IsServiceRunningRequestEvent;
import net.kaaass.zerotierfix.events.ManualDisconnectEvent;
import net.kaaass.zerotierfix.events.NetworkConfigChangedByUserEvent;
import net.kaaass.zerotierfix.events.NetworkListReplyEvent;
import net.kaaass.zerotierfix.events.NetworkListRequestEvent;
import net.kaaass.zerotierfix.events.NetworkReconfigureEvent;
import net.kaaass.zerotierfix.events.NodeDestroyedEvent;
import net.kaaass.zerotierfix.events.NodeIDEvent;
import net.kaaass.zerotierfix.events.NodeStatusEvent;
import net.kaaass.zerotierfix.events.NodeStatusRequestEvent;
import net.kaaass.zerotierfix.events.OrbitMoonEvent;
import net.kaaass.zerotierfix.events.PeerInfoReplyEvent;
import net.kaaass.zerotierfix.events.NetworkListRequestEvent;
import net.kaaass.zerotierfix.events.NodeStatusRequestEvent;
import net.kaaass.zerotierfix.events.PeerInfoRequestEvent;
import net.kaaass.zerotierfix.events.StopEvent;
import net.kaaass.zerotierfix.events.VPNErrorEvent;
Expand Down Expand Up @@ -392,51 +391,53 @@ public int onStartCommand(Intent intent, int flags, int startId) {

// 创建本地节点
if (this.node == null) {
this.udpCom = new UdpCom(this, this.svrSocket);
this.tunTapAdapter = new TunTapAdapter(this, networkId);

// 创建节点对象并初始化
var dataStore = this.dataStore;
this.node = new Node(System.currentTimeMillis());
var result = this.node.init(dataStore, dataStore, this.udpCom, this, this.tunTapAdapter, this, null);

if (result == ResultCode.RESULT_OK) {
Log.d(TAG, "ZeroTierOne Node Initialized");
} else {
Log.e(TAG, "Error starting ZT1 Node: " + result);
return START_NOT_STICKY;
}
this.onNodeStatusRequest(null);

// 持久化当前节点信息
long address = this.node.address();
DatabaseUtils.writeLock.lock();
try {
this.udpCom = new UdpCom(this, this.svrSocket);
this.tunTapAdapter = new TunTapAdapter(this, networkId);

// 创建节点对象并初始化
var dataStore = this.dataStore;
this.node = new Node(System.currentTimeMillis());
this.node.init(dataStore, dataStore, this.udpCom, this, this.tunTapAdapter, this, null);
this.onNodeStatusRequest(null);

// 持久化当前节点信息
long address = this.node.address();
DatabaseUtils.writeLock.lock();
try {
var appNodeDao = ((ZerotierFixApplication) getApplication())
.getDaoSession().getAppNodeDao();
var nodesList = appNodeDao.queryBuilder().build()
.forCurrentThread().list();
if (nodesList.isEmpty()) {
var appNode = new AppNode();
appNode.setNodeId(address);
appNode.setNodeIdStr(String.format("%10x", address));
appNodeDao.insert(appNode);
} else {
var appNode = nodesList.get(0);
appNode.setNodeId(address);
appNode.setNodeIdStr(String.format("%10x", address));
appNodeDao.save(appNode);
}
} finally {
DatabaseUtils.writeLock.unlock();
var appNodeDao = ((ZerotierFixApplication) getApplication())
.getDaoSession().getAppNodeDao();
var nodesList = appNodeDao.queryBuilder().build()
.forCurrentThread().list();
if (nodesList.isEmpty()) {
var appNode = new AppNode();
appNode.setNodeId(address);
appNode.setNodeIdStr(String.format("%10x", address));
appNodeDao.insert(appNode);
} else {
var appNode = nodesList.get(0);
appNode.setNodeId(address);
appNode.setNodeIdStr(String.format("%10x", address));
appNodeDao.save(appNode);
}
} finally {
DatabaseUtils.writeLock.unlock();
}

this.eventBus.post(new NodeIDEvent(address));
this.udpCom.setNode(this.node);
this.tunTapAdapter.setNode(this.node);
this.eventBus.post(new NodeIDEvent(address));
this.udpCom.setNode(this.node);
this.tunTapAdapter.setNode(this.node);

// 启动 UDP 消息处理线程
var thread = new Thread(this.udpCom, "UDP Communication Thread");
this.udpThread = thread;
thread.start();
} catch (NodeException e) {
Log.e(TAG, "Error starting ZT1 Node: " + e.getMessage(), e);
return START_NOT_STICKY;
}
// 启动 UDP 消息处理线程
var thread = new Thread(this.udpCom, "UDP Communication Thread");
this.udpThread = thread;
thread.start();
}

// 创建并启动 VPN 服务线程
Expand Down
2 changes: 1 addition & 1 deletion externals/core
Submodule core updated 540 files

0 comments on commit 99e7c71

Please sign in to comment.