mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Don't allow configuring the same peer more than once
This commit is contained in:
		
							parent
							
								
									8cf76f841d
								
							
						
					
					
						commit
						428d2375da
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		| 
						 | 
					@ -188,6 +188,13 @@ func (c *Core) SetLogger(log util.Logger) {
 | 
				
			||||||
// This adds the peer to the peer list, so that they will be called again if the
 | 
					// This adds the peer to the peer list, so that they will be called again if the
 | 
				
			||||||
// connection drops.
 | 
					// connection drops.
 | 
				
			||||||
func (c *Core) AddPeer(uri string, sourceInterface string) error {
 | 
					func (c *Core) AddPeer(uri string, sourceInterface string) error {
 | 
				
			||||||
 | 
						var known bool
 | 
				
			||||||
 | 
						phony.Block(c, func() {
 | 
				
			||||||
 | 
							_, known = c.config._peers[Peer{uri, sourceInterface}]
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if known {
 | 
				
			||||||
 | 
							return fmt.Errorf("peer already configured")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	u, err := url.Parse(uri)
 | 
						u, err := url.Parse(uri)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue