Config/Interface: Allow copyFrom() to work on null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									d3e6b311ca
								
							
						
					
					
						commit
						0e46f95668
					
				| @ -61,12 +61,21 @@ public class Config extends BaseObservable | ||||
| 
 | ||||
|     @Override | ||||
|     public void copyFrom(final Config source) { | ||||
|         iface.copyFrom(source.iface); | ||||
|         isEnabled = source.isEnabled; | ||||
|         name = source.name; | ||||
|         peers.clear(); | ||||
|         for (final Peer peer : source.peers) | ||||
|             addPeer(peer); | ||||
|         if (source != null) { | ||||
|             iface.copyFrom(source.iface); | ||||
|             isEnabled = source.isEnabled; | ||||
|             isPrimary = source.isPrimary; | ||||
|             name = source.name; | ||||
|             peers.clear(); | ||||
|             for (final Peer peer : source.peers) | ||||
|                 addPeer(peer); | ||||
|         } else { | ||||
|             iface.copyFrom(null); | ||||
|             isEnabled = false; | ||||
|             isPrimary = false; | ||||
|             name = null; | ||||
|             peers.clear(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public Interface getInterface() { | ||||
|  | ||||
| @ -29,11 +29,19 @@ public class Interface extends BaseObservable implements Copyable<Interface>, Ob | ||||
| 
 | ||||
|     @Override | ||||
|     public void copyFrom(final Interface source) { | ||||
|         address = source.address; | ||||
|         dns = source.dns; | ||||
|         listenPort = source.listenPort; | ||||
|         setPrivateKey(source.privateKey); | ||||
|         mtu = source.mtu; | ||||
|         if (source != null) { | ||||
|             address = source.address; | ||||
|             dns = source.dns; | ||||
|             listenPort = source.listenPort; | ||||
|             mtu = source.mtu; | ||||
|             setPrivateKey(source.privateKey); | ||||
|         } else { | ||||
|             address = null; | ||||
|             dns = null; | ||||
|             listenPort = null; | ||||
|             mtu = null; | ||||
|             setPrivateKey(null); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void generateKeypair() { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user