1
1
package pcl .opensecurity .drivers ;
2
2
3
+ import java .util .Iterator ;
4
+
3
5
import pcl .opensecurity .OpenSecurity ;
4
6
import li .cil .oc .api .Network ;
5
7
import li .cil .oc .api .driver .EnvironmentHost ;
14
16
15
17
public class SecureNetworkCardDriver extends NetworkCard {
16
18
17
- public final EnvironmentHost container ;
19
+ public final li . cil . oc . api . network . EnvironmentHost container ;
18
20
private ComponentConnector node ;
19
21
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 ;
23
25
this .setNode (Network .newNode (this , Visibility .Network )
24
26
.withComponent ("modem" , Visibility .Neighbors )
25
27
.withConnector (1 )
@@ -29,20 +31,32 @@ public SecureNetworkCardDriver(EnvironmentHost container) {
29
31
@ Callback (doc = "function() -- Randomises the UUID" )
30
32
public Object [] generateUUID (Context context , Arguments args ) {
31
33
//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 };
39
53
//} else {
40
- //return new Object[] { false };
54
+ //return new Object[] { false };
41
55
//}
42
56
}
43
57
44
58
@ Override
45
- public EnvironmentHost host () {
59
+ public li . cil . oc . api . network . EnvironmentHost host () {
46
60
return this .container ;
47
61
}
48
62
0 commit comments