Skip to content

Commit 07ebe04

Browse files
committedApr 17, 2016
SecureNetworkDriver
1 parent 4b7924a commit 07ebe04

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed
 

Diff for: ‎src/main/java/pcl/opensecurity/drivers/SecureNetworkCardDriver.java

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pcl.opensecurity.drivers;
22

3+
import java.util.Iterator;
4+
35
import pcl.opensecurity.OpenSecurity;
46
import li.cil.oc.api.Network;
57
import li.cil.oc.api.driver.EnvironmentHost;
@@ -14,12 +16,12 @@
1416

1517
public class SecureNetworkCardDriver extends NetworkCard {
1618

17-
public final EnvironmentHost container;
19+
public final li.cil.oc.api.network.EnvironmentHost container;
1820
private ComponentConnector node;
1921

20-
public SecureNetworkCardDriver(EnvironmentHost container) {
21-
super(container);
22-
this.container = container;
22+
public SecureNetworkCardDriver(li.cil.oc.api.network.EnvironmentHost arg1) {
23+
super(arg1);
24+
this.container = arg1;
2325
this.setNode(Network.newNode(this, Visibility.Network)
2426
.withComponent("modem", Visibility.Neighbors)
2527
.withConnector(1)
@@ -29,20 +31,32 @@ public SecureNetworkCardDriver(EnvironmentHost container) {
2931
@Callback(doc = "function() -- Randomises the UUID")
3032
public Object[] generateUUID(Context context, Arguments args) {
3133
//if(node.tryChangeBuffer(1)) {
32-
this.node.remove();
33-
this.setNode(Network.newNode(this, Visibility.Network)
34-
.withComponent("modem", Visibility.Neighbors)
35-
.withConnector(1)
36-
.create());
37-
OpenSecurity.logger.info(this.node.address());
38-
return new Object[] { true };
34+
//<@Sangar> well, in that case your best bet is to store its neighbors before disconnecting, then reconnect to them all
35+
OpenSecurity.logger.info(this.node.address());
36+
Iterable<Node> tempNodes = this.node().neighbors();
37+
38+
this.node.remove();
39+
this.node = Network.newNode(this, Visibility.Network)
40+
.withComponent("modem", Visibility.Neighbors)
41+
.withConnector(1)
42+
.create();
43+
44+
Iterator<Node> meh = tempNodes.iterator();
45+
46+
//OpenSecurity.logger.info(this.node());
47+
while (meh.hasNext()) {
48+
this.node().connect(meh.next());
49+
}
50+
51+
OpenSecurity.logger.info(this.node.address());
52+
return new Object[] { true };
3953
//} else {
40-
//return new Object[] { false };
54+
//return new Object[] { false };
4155
//}
4256
}
4357

4458
@Override
45-
public EnvironmentHost host() {
59+
public li.cil.oc.api.network.EnvironmentHost host() {
4660
return this.container;
4761
}
4862

0 commit comments

Comments
 (0)
Please sign in to comment.