Fixed UAPI deadlock
This commit is contained in:
		
							parent
							
								
									086d32186a
								
							
						
					
					
						commit
						2a6dd2ed92
					
				
					 2 changed files with 4 additions and 9 deletions
				
			
		|  | @ -106,17 +106,17 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { | ||||||
| 		key := parts[0] | 		key := parts[0] | ||||||
| 		value := parts[1] | 		value := parts[1] | ||||||
| 
 | 
 | ||||||
|  | 		fmt.Println(key, value) | ||||||
|  | 
 | ||||||
| 		switch key { | 		switch key { | ||||||
| 
 | 
 | ||||||
| 		/* interface configuration */ | 		/* interface configuration */ | ||||||
| 
 | 
 | ||||||
| 		case "private_key": | 		case "private_key": | ||||||
|  | 			var sk NoisePrivateKey | ||||||
| 			if value == "" { | 			if value == "" { | ||||||
| 				device.mutex.Lock() | 				device.SetPrivateKey(sk) | ||||||
| 				device.privateKey = NoisePrivateKey{} |  | ||||||
| 				device.mutex.Unlock() |  | ||||||
| 			} else { | 			} else { | ||||||
| 				var sk NoisePrivateKey |  | ||||||
| 				err := sk.FromHex(value) | 				err := sk.FromHex(value) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					logError.Println("Failed to set private_key:", err) | 					logError.Println("Failed to set private_key:", err) | ||||||
|  | @ -183,9 +183,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { | ||||||
| 			switch key { | 			switch key { | ||||||
| 
 | 
 | ||||||
| 			case "remove": | 			case "remove": | ||||||
| 				peer.mutex.Lock() |  | ||||||
| 				device.RemovePeer(peer.handshake.remoteStatic) | 				device.RemovePeer(peer.handshake.remoteStatic) | ||||||
| 				peer.mutex.Unlock() |  | ||||||
| 				logDebug.Println("Removing", peer.String()) | 				logDebug.Println("Removing", peer.String()) | ||||||
| 				peer = nil | 				peer = nil | ||||||
| 
 | 
 | ||||||
|  | @ -236,7 +234,6 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { | ||||||
| 					return &IPCError{Code: ipcErrorInvalidValue} | 					return &IPCError{Code: ipcErrorInvalidValue} | ||||||
| 				} | 				} | ||||||
| 				ones, _ := network.Mask.Size() | 				ones, _ := network.Mask.Size() | ||||||
| 				logError.Println(network, ones, network.IP) |  | ||||||
| 				device.routingTable.Insert(network.IP, uint(ones), peer) | 				device.routingTable.Insert(network.IP, uint(ones), peer) | ||||||
| 
 | 
 | ||||||
| 			default: | 			default: | ||||||
|  |  | ||||||
|  | @ -253,8 +253,6 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer { | ||||||
| 		} | 		} | ||||||
| 		hash = mixHash(hash, msg.Timestamp[:]) | 		hash = mixHash(hash, msg.Timestamp[:]) | ||||||
| 
 | 
 | ||||||
| 		// TODO: check for flood attack
 |  | ||||||
| 
 |  | ||||||
| 		// check for replay attack
 | 		// check for replay attack
 | ||||||
| 
 | 
 | ||||||
| 		return timestamp.After(handshake.lastTimestamp) | 		return timestamp.After(handshake.lastTimestamp) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue