mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Fix Peers and InterfacePeers when not in correct format
This commit is contained in:
		
							parent
							
								
									10157483f9
								
							
						
					
					
						commit
						ccf6ce07a4
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
					@ -12,6 +12,7 @@ import (
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"os/signal"
 | 
						"os/signal"
 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"syscall"
 | 
						"syscall"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,6 +189,25 @@ func main() {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							// Check to see if the peers are in a parsable format, if not then default
 | 
				
			||||||
 | 
							// them to the TCP scheme
 | 
				
			||||||
 | 
							for index, peer := range dat["Peers"].([]interface{}) {
 | 
				
			||||||
 | 
								uri := peer.(string)
 | 
				
			||||||
 | 
								if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								(dat["Peers"].([]interface{}))[index] = "tcp://" + uri
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							// Now do the same with the interface peers
 | 
				
			||||||
 | 
							for intf, peers := range dat["InterfacePeers"].(map[string]interface{}) {
 | 
				
			||||||
 | 
								for index, peer := range peers.([]interface{}) {
 | 
				
			||||||
 | 
									uri := peer.(string)
 | 
				
			||||||
 | 
									if strings.HasPrefix(uri, "tcp://") || strings.HasPrefix(uri, "socks://") {
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									((dat["InterfacePeers"].(map[string]interface{}))[intf]).([]interface{})[index] = "tcp://" + uri
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		// Overlay our newly mapped configuration onto the autoconf node config that
 | 
							// Overlay our newly mapped configuration onto the autoconf node config that
 | 
				
			||||||
		// we generated above.
 | 
							// we generated above.
 | 
				
			||||||
		if err = mapstructure.Decode(dat, &cfg); err != nil {
 | 
							if err = mapstructure.Decode(dat, &cfg); err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue